IOleUndoUnit  2YE4ME

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::GetOpenParentStateJHDJIP 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::Add214XCVW 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 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.

Methods in VTable Order

IUnknown1NEM0LU Methods

Description

QueryInterface2Y54585

Returns a pointer to a specified interface.

AddRef1SHW0SS

Increments the reference count.

ReleaseDUW01A

Decrements the reference count.

 

IOleUndoUnit Methods

Description

Do1SALTDA

Instructs the undo unit to carry out its action.

GetDescription14AQ.GM

Returns a string that describes the undo unit and can be used in the undo or redo user interface.

GetUnitTypeHQUGXH

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

OnNextAddO1NV2N

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

 

See Also

IOleParentUndoUnit, IOleUndoManager