![]() |
|
#1
|
|||
|
|||
Undo DrawingHi Hi,
I have a draw function which is drawing 25 rectangle on mouse click on my Scroll view, which is the main viewclass. I have another Form view which contains some 25 Radiobuttons and Edit controls. When I click on the radio button, then click on the main, it draws the rectangle and displays the cordinate in the edit controls in the formview. CPP / C++ / C Code:
I need to be able to undo the drawing, lets say I've click it in the wrong place, then re-click in the right position. In other words, how can I undo the drawing of the rectangle. Please can anyone help..... Last edited by dsmith : 10-May-2004 at 07:29.
Reason: Use [c] & [/c] for C-syntax highlighting
|
|
#2
|
||||
|
||||
|
Hmmm... I would have a couple of global variables that store identifiers to describe what the user just did, and what the user did before that. Or you could even make a linked list of the user's actions. Then, to undo, all you have to do is clear the screen and draw what happened last time the user did something.
__________________
-Aaron |
|
#3
|
||||
|
||||
|
The simplest way to do this is by using stack. you push user action and just simply pop when you want undo. Are you using MFC here?? THe you should look at this article, it may help:
UndoRedo1 There more if you search the site. Using linked list is also a fine idea, but what is important is what and how you store the user action. Redrawing it is not that hard but it could be slow.. __________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
|
#4
|
||||
|
||||
|
I haven't learned about stacks yet, so that was my only idea, and yeah... I realized it might take up a few more cycles than are really necessary :-P
__________________
-Aaron |
Recent GIDBlog
Python ebook by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| drawing dot and rect | Nelly | MS Visual C++ / MFC Forum | 2 | 22-Apr-2004 13:09 |
| Back to the drawing board... | spudtheimpaler | C Programming Language | 9 | 15-Mar-2004 10:12 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The