This is very useful code. Thanks. I fixed what seem to me to be a couple of bugs.
Bug 1
If the Delete key is used to delete the next character, status will not get updated.
Fix For Bug 1
In
Code:RichTextBox1_KeyDown
, after
Code:.ModifyType = urDeleteText
AddToUndoStack cUndo
I added
Code:UpdateStatus
This is necessary because, if you just delete the next character, you have not changed the selection start point or the selection length (0), so
Code:RichTextBox1_SelChange
, which includes a call of
Code:UpdateStatus
, will not get triggered.
Bug 2
After a redo followed by an undo, the redo could not be done again.
Maybe this is supposed to be a feature rather than a bug, but I think it is a bug: that is not how Microsoft Word or the VB6 editor behave, and I do not want it to happen in my program.
Fix For Bug 2
Delete the following code.
Code:Private Sub RichTextBox1_Change()
If bRedoing Then
bRedoing = False
ClearStack RedoStack
End If
End Sub