Solved

Undo / Redo

Posted on 1997-09-04
5
621 Views
Last Modified: 2013-11-20
I am implementing a graphical newtork editor in Visual C++ 5.0 running on the Windows NT 4.0 platform. This editor should support multiple undo / redo functionality.

I have looked in all available MFC / OLE / COM books and in the online help in DevStudio and the only information I have found has been the manual pages for:
      IOleUndoManager
      IOleUndoUnit
      IOleParentUndoUnit

In my opinion these man pages are very difficult to understand especially since no examples are included with them.

Is there anyone out there who can give me any information and perhaps examples on how undo / redo is best implemented using MFC.
0
Comment
Question by:julieb
5 Comments
 
LVL 3

Expert Comment

by:byang
ID: 1305783
Trap undo/redo keys and handle them yourself. For contained OLE objects, just pump the keyboard input to them.
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1305784
The concept of undo and redo was hard for me to understand until I read that the state of the application is captured by the undo and redo.

For example, let's say that you want to create a graphical editor that lets you draw lines and circles and such. So when a user draws a line, you catch the difference of the state of the application before and after drawing that line and store that within an object and store that object within a list (because you want to support more than one level of undo). Then if the user decides to undo that line, the object knows what was affected by that line and restores everything back. Of course, if the user wants to redo, the object is still in the list and knows how to put the line back.

If you want to read more about undo/redo objects, I recommend you pick up the book Design Patterns by Gamma et al. It is a really good book on designing applications with C++.
0
 

Author Comment

by:julieb
ID: 1305786
No pointers on how to implement Undo / Redo best in MFC
0
 
LVL 8

Expert Comment

by:gelbert
ID: 1305785
Check http://web.ukonline.co.uk/Members/julian.smart/code.html. You can find sample code there called "Command/Undo"
0
 
LVL 1

Accepted Solution

by:
kargo earned 100 total points
ID: 1305787
What we did here was to use serialization into a memory file of the document components that change.  Basically the components that are possible to change are small.  We wrapped them into a class that supports serialization.  Then when a process is done the parts get serialized into a memory file which we then keep the HGLOBAL.  If the user does an undo we deserialize the last HGLOBAL.  The application uses a round buffer to manage many HGLOBALs allowing us to have multilayer undo/redo.  The pointers are manages using a double link (next/Prev).  We use memory for speed.

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA "SendKeys" Syntax for Multiple Keystrokes 7 108
Doc'in system (example?) BA 7 107
sum13 challenge 24 106
withoutTen challenge 14 120
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question