The IOleUndoUnit interface is the main interface on an undo unit. An undo unit encapsulates the information necessary to undo or redo a single action.
When an object's state changes and it needs to create an undo unit, it first needs to know what parent units are open. It calls the IOleUndoManager::GetOpenParentState method to determine this. If the call returns S_FALSE, then there is no enabling parent. If the call returns S_OK but the UAS_NOPARENTENABLE flag is set, then the open parent is a disabling parent. In either of these cases, the object calls IOleUndoManager::DiscardFrom(NULL) on the undo manager and skips creating the undo unit.
If the method returns S_OK, but the UAS_BLOCKED flag is set, then the open parent is a blocking parent. The object does not need to create an undo unit, since it would be immediately discarded. If the return value is S_OK and neither of the bit flags are set, then the object creates the undo unit and calls IOleUndoManager::Add on the undo manager.
The object should retain a pointer to the undo manager.
An object creates an undo unit that implements this interface when the end user has performed an action that can be undone. The object calls the IOleUndoManager::Add method to add the undo unit to the undo stack. Most controls can implement this interface to support the centralized undo operations. They do not have to implement IOleParentUndoUnit or IOleUndoManager. The undo manager with the IOleUndoManager interface is usually provided by the object container.
The undo manager calls the Do and GetDescription methods in this interface to perform undo actions and to get strings that can be displayed in the user interface to describe the undo action. A parent undo unit can call the GetUnitType and OnNextAdd methods.
IUnknown Methods | Description |
---|---|
QueryInterface | Returns a pointer to a specified interface. |
AddRef | Increments the reference count. |
Release | Decrements the reference count. |
IOleUndoUnit Methods | Description |
---|---|
Do | Instructs the undo unit to carry out its action. |
GetDescription | Returns a string that describes the undo unit and can be used in the undo or redo user interface. |
GetUnitType | Returns the CLSID and a type identifier for the undo unit. |
OnNextAdd | Notifies the last undo unit in the collection that a new unit has been added. |
Windows NT: Use version 4.0 or later. New for OC96.
Windows: Use Windows 95 or later. New for OC96.
Windows CE: Unsupported.
Header: Declared in ocidl.h.
IOleParentUndoUnit, IOleUndoManager