I got interested in using the API to emulate the text box popup mneu after the discussion in thread222-1379849. I have most of it together, but I'm having trouble with a couple of things. I presently have the menu itself working, and the Undo feature. Now I'm working on the Delete. I have the following code for Undo (all the necessary declares and constant definitions are in place):
[tt]Public Sub ProcessUndoSelection(cCtl As Control)
If SendMessage(cCtl.hwnd, EM_CANUNDO, 0, 0) <> 0 Then
SendMessage cCtl.hwnd, EM_UNDO, 0, 0
End If
End Sub
[/tt]
This works if I just use keystrokes to alter the text in the box. However, if I programmatically change the contents of the text box it doesn't work, for example when I do this to support the Delete selection:
[tt]
Public Sub ProcessDelete(cCtl As Control, cForm As Form)
Dim cSelStart as Integer
With Text1
cSelStart = .SelStart
.Text = Replace(.Text, .SelText, "")
.SelStart = cSelStart
End With
[/tt]
After doing this, selecting Undo doesn't replace the deleted text. It looks pretty clear that there's an undo buffer that gets blanked in this situation, and I don't know how to either prevent that or store the deleted text to the buffer. I'm pretty sure there must be something like that that one can do. Can someone help?
TIA
Bob
[tt]Public Sub ProcessUndoSelection(cCtl As Control)
If SendMessage(cCtl.hwnd, EM_CANUNDO, 0, 0) <> 0 Then
SendMessage cCtl.hwnd, EM_UNDO, 0, 0
End If
End Sub
[/tt]
This works if I just use keystrokes to alter the text in the box. However, if I programmatically change the contents of the text box it doesn't work, for example when I do this to support the Delete selection:
[tt]
Public Sub ProcessDelete(cCtl As Control, cForm As Form)
Dim cSelStart as Integer
With Text1
cSelStart = .SelStart
.Text = Replace(.Text, .SelText, "")
.SelStart = cSelStart
End With
[/tt]
After doing this, selecting Undo doesn't replace the deleted text. It looks pretty clear that there's an undo buffer that gets blanked in this situation, and I don't know how to either prevent that or store the deleted text to the buffer. I'm pretty sure there must be something like that that one can do. Can someone help?
TIA
Bob