IOleUndoUnit interface

Serves as 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.

When to implement

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.

When to use

The undo manager calls the IOleUndoUnit::Do and IOleUndoUnit::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 IOleUndoUnit::GetUnitType and IOleUndoUnit::OnNextAdd methods.


The IOleUndoUnit interface inherits from the IUnknown interface. IOleUndoUnit also has these types of members:


The IOleUndoUnit interface has these methods.


Instructs the undo unit to carry out its action.


Retrieves the description of the undo unit that can be used in the undo or redo user interface.


Retrieves the CLSID and a type identifier for the undo unit.


Notifies the last undo unit in the collection that a new unit has been added.



Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]






IID_IOleUndoUnit is defined as 894AD3B0-EF97-11CE-9BC9-00AA00608E01

See also




Community Additions

© 2015 Microsoft