VB设计的记事本*有撤销功能*

来源:百度知道 编辑:UC知道 时间:2024/05/17 14:46:04
急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!编程高手你在哪里????????????????????????请大家都来帮帮忙……
~~>_<~~ ~~>_<~~ ~~>_<~~ ~~>_<~~ ~~>_<~~ ~~>_<~~ ~~>_<~~
谢谢!谢谢!谢谢!谢谢!谢谢!谢谢!谢谢!谢谢!谢谢!谢谢!谢谢!谢谢!谢谢!

每次更改text1.text时候的,把内容保存一下。
用 SendMessage API 函数向 TextBox 发送 EM_UNDO 消息,要确定 TextBox 是否可以 Undo,发送 EM_CANUNDO 消息。

'控件:Text1、Command1、Command2。

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Const EM_UNDO = &HC7
Private Const EM_CANUNDO = &HC6

Private Sub Command1_Click() '确定是否可以 Undo。
If SendMessage(Text1.hwnd, EM_CANUNDO, 0, 0) Then
MsgBox "现在可以 Undo."
Else
MsgBox "现在不可以 Undo."
End If
End Sub

Private Sub Command2_Click() 'Undo。
Call SendMessage(Text1.hwnd, EM_UNDO, 0, 0)
End Sub

Public Sub Undo()
Dim chg$, X&
Dim DeleteFlag As Boolean 'flag as to whether or not to delete text or append text
Dim objElement As Object, objElement2 As Object
If UndoStac