rich text box issue

C

Catherine Jones

I have one more issue, please help me to find the solution ,
My question as follows..

In the rich text box, after an undo or redo operation how can we get
information on the following things..
1) which operation has happened(paste, insert or overwrite)
2) Which line numbers are affected by the undo/redo operation
3) How can we get the newly inserted text.

Looking forward for your reply..
Warm Regards
 
R

Robert Jacobson

The .UndoActionName and .RedoActionName properties should help you with step
1. They will identify which operation _will_ occur if an undo or redo
operation is made. You'd have to monitor these properties, so if the
UndoActionName is "paste" (or whatever value it actually is) and the user
then selects undo, you'd know that a paste was undone.

For steps 2 and 3, you could write an algorithm to compare the old text to
the new text. To identify where the change occurred in the document, you
could use something like the following pseudocode:

For i = 0 to LengthOfDocument
If OldDocument.Character(i) <> NewDocument.Character(i) then
StartOfChange = i
Exit For
End If
Next i

For j = LengthOfDocument to 0 Step -1
If OldDocument.Character(j) <> NewDocument.Character(j) then
EndOfChange = i
Exit For
End If
Next j

Hope this helps,
Robert Jacobson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top