Please Help: Multiple level of UNDO's in a Rich Text Box (thanks!) 
Author Message
 Please Help: Multiple level of UNDO's in a Rich Text Box (thanks!)

Hello,

I have made a simple text editor using a Rich Text Box control,
and would like to implement an Undo function simliar to VB5's
IDE. It would have up to ten undo's stored in memory. I would
also like to store a small text description for each undo, that
would be generated depending on the user-generated event.
That way I could modify the Undo button's tooltip property at
runtime, exactly like in VB5's IDE.

How is it possible to do that? I think I need to store the
description of the undo as well as a copy of RTB.RTFText at
the time the change was made by the user. And each time
a change is made, increment all the undo's by one.

These are all concepts, I have no idea how to realize what I'm
trying to do. Can you tell me how? Is there a better way to do it?
Any help is appreciated!

Thanks!

Ron.



Sun, 27 Aug 2000 03:00:00 GMT  
 Please Help: Multiple level of UNDO's in a Rich Text Box (thanks!)

Off the top of my head... I would use two arrays. The first would store the
text from the rtfTextBox. The second would store the associated ToolTip
text. Also a global variable--an undo counter--would be needed.

There is an event called SelChange that occurs everytime a user does
anything to a rtf textbox--moves the insertion point, types something, uses
the mouse to highlight something, etc.

Whenever the SelChange event occurs, compare the current rtf text to the
previous text (in the array). If there is a change, increment the undo
counter and store the contents of the rtf box in the array. If the undo
counter reaches, say 10 or whatever, then reset it to 1 and start
overwriting the contents of the array.

When the user clicks the undo button, replace the contents of the rtf box
with the contents of the array.

This is kinda vague, I know, but it's an idea.

Eric Sopher

Quote:

>Hello,

>I have made a simple text editor using a Rich Text Box control,
>and would like to implement an Undo function simliar to VB5's
>IDE. It would have up to ten undo's stored in memory. I would
>also like to store a small text description for each undo, that
>would be generated depending on the user-generated event.
>That way I could modify the Undo button's tooltip property at
>runtime, exactly like in VB5's IDE.

>How is it possible to do that? I think I need to store the
>description of the undo as well as a copy of RTB.RTFText at
>the time the change was made by the user. And each time
>a change is made, increment all the undo's by one.

>These are all concepts, I have no idea how to realize what I'm
>trying to do. Can you tell me how? Is there a better way to do it?
>Any help is appreciated!

>Thanks!

>Ron.



Sat, 02 Sep 2000 03:00:00 GMT  
 Please Help: Multiple level of UNDO's in a Rich Text Box (thanks!)

Eric,

Thanks a lot.
I'll try and do this.

Ron.

Quote:

>Off the top of my head... I would use two arrays. The first would store the
>text from the rtfTextBox. The second would store the associated ToolTip
>text. Also a global variable--an undo counter--would be needed.

>There is an event called SelChange that occurs everytime a user does
>anything to a rtf textbox--moves the insertion point, types something, uses
>the mouse to highlight something, etc.

>Whenever the SelChange event occurs, compare the current rtf text to the
>previous text (in the array). If there is a change, increment the undo
>counter and store the contents of the rtf box in the array. If the undo
>counter reaches, say 10 or whatever, then reset it to 1 and start
>overwriting the contents of the array.

>When the user clicks the undo button, replace the contents of the rtf box
>with the contents of the array.

>This is kinda vague, I know, but it's an idea.

>Eric Sopher


>>Hello,

>>I have made a simple text editor using a Rich Text Box control,
>>and would like to implement an Undo function simliar to VB5's
>>IDE. It would have up to ten undo's stored in memory. I would
>>also like to store a small text description for each undo, that
>>would be generated depending on the user-generated event.
>>That way I could modify the Undo button's tooltip property at
>>runtime, exactly like in VB5's IDE.

>>How is it possible to do that? I think I need to store the
>>description of the undo as well as a copy of RTB.RTFText at
>>the time the change was made by the user. And each time
>>a change is made, increment all the undo's by one.

>>These are all concepts, I have no idea how to realize what I'm
>>trying to do. Can you tell me how? Is there a better way to do it?
>>Any help is appreciated!

>>Thanks!

>>Ron.



Sat, 02 Sep 2000 03:00:00 GMT  
 Please Help: Multiple level of UNDO's in a Rich Text Box (thanks!)

On Tue, 17 Mar 1998 03:50:59 -0600, "Eric Sopher"

Quote:

>Off the top of my head... I would use two arrays. The first would store the
>text from the rtfTextBox. The second would store the associated ToolTip
>text. Also a global variable--an undo counter--would be needed.

>There is an event called SelChange that occurs everytime a user does
>anything to a rtf textbox--moves the insertion point, types something, uses
>the mouse to highlight something, etc.

>Whenever the SelChange event occurs, compare the current rtf text to the
>previous text (in the array). If there is a change, increment the undo
>counter and store the contents of the rtf box in the array. If the undo
>counter reaches, say 10 or whatever, then reset it to 1 and start
>overwriting the contents of the array.

>When the user clicks the undo button, replace the contents of the rtf box
>with the contents of the array.

>This is kinda vague, I know, but it's an idea.

>Eric Sopher


There is a potential hazard if you store the TextRTF in a String
variable as there is a maximum size (64k) for a String, while the RTF
control can happily load multi-Megabyte files.
 You could have an array of hidden RTF controls, but this may be a
little heavy on resources.
Ideally you need a way to just store the changes made, but at the
moment I can't think of an easy way to do this.
Best Regards.
Dave.


Sat, 02 Sep 2000 03:00:00 GMT  
 Please Help: Multiple level of UNDO's in a Rich Text Box (thanks!)

I did something like this a while back. I don't remember all the details at
the moment. I'm at work and the code's at home, but in essence what I did
was save the position of the insertion point, whether text was added or
deleted, and what the text was. I *think* I did this with an array of Type
variables, something like this:

            Type UndoType
                InsertionPointLocation As Long
                AddOrDelete As Integer
                TextAddedOrDeleted As String
            End Type

Then whenever a change is made save the data. The only problem I ran into
with this is that whenever you were typing in text and wanted to undo it you
have to undo one character at a time.

                                                                        Matt

--
SPAM Bait:








Board of the FCC





And let's help you send some spam to the USPS, too:

Quote:

>On Tue, 17 Mar 1998 03:50:59 -0600, "Eric Sopher"

>>Off the top of my head... I would use two arrays. The first would store
the
>>text from the rtfTextBox. The second would store the associated ToolTip
>>text. Also a global variable--an undo counter--would be needed.

>>There is an event called SelChange that occurs everytime a user does
>>anything to a rtf textbox--moves the insertion point, types something,
uses
>>the mouse to highlight something, etc.

>>Whenever the SelChange event occurs, compare the current rtf text to the
>>previous text (in the array). If there is a change, increment the undo
>>counter and store the contents of the rtf box in the array. If the undo
>>counter reaches, say 10 or whatever, then reset it to 1 and start
>>overwriting the contents of the array.

>>When the user clicks the undo button, replace the contents of the rtf box
>>with the contents of the array.

>>This is kinda vague, I know, but it's an idea.

>>Eric Sopher

>There is a potential hazard if you store the TextRTF in a String
>variable as there is a maximum size (64k) for a String, while the RTF
>control can happily load multi-Megabyte files.
> You could have an array of hidden RTF controls, but this may be a
>little heavy on resources.
>Ideally you need a way to just store the changes made, but at the
>moment I can't think of an easy way to do this.
>Best Regards.
>Dave.



Tue, 12 Sep 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Please Help: Multiple level of UNDO's in a Rich Text Box (thanks!)

2. Please Help: Multiple level of UNDO's in a Rich Text Box (thanks!)

3. using rich text box undo/redo properly?

4. Rich Text Box - Undo

5. To invoke undo command in Rich Text Box

6. help: formatting rich text box/text box

7. Rich Text Box Help Please...

8. Help with rich text box please!!!

9. Fonts Common Dialog and Rich Text Box problem...please help

10. Please Help w\Rich Text Box before my Head EXPLODES

11. Help please with Rich Text Box Flicker

12. Setting printing margins for rich text box - please help

 

 
Powered by phpBB® Forum Software