Well i want to know the best way of doing this.
Posted on 2004-10-04 08:21:39 by AceEmbler
One way of doing it is by remembering 'actions' and knowing each action's 'counter-action' (the one that will undo it). You then have a stack-like container for the actions.

Another way is by having a stack-like container for states. While sometimes simpler, this approach is much more wasteful.

After having the container, which I'll call 'undo container', you can also have a 'redo container'. Every time you pop an element from the undo container, you actually move it to the redo container and vice versa. When you push a new element to the undo stack you clear the redo container.

Why do I say stack-like and not stack?
1. You may want to access the elements without modifying the container state (e.g. displaying elements in container to the user).
2. The container might decide to 'lose' elements after some boundary count, for example to save memory.

These are the basics of undo/redo that I have dealt with in the past.
Posted on 2004-10-04 13:47:14 by death
Use an array of pointers to point to an 'array' of bitmaps and SelectObject the one to use.

You can precreate the bitmaps for each action or group of actions. Keep it revolving so you don't run out of memory, if you want alot of undo levels, maybe read/write them to a temp file on disk and use file pointers, relatively speaking - pun intended.
Posted on 2004-10-05 17:43:11 by drarem