Undoing Automation Operations

The LEADTOOLS OCX features include an Undo engine for undoing annotation automation operations. The undo depth determines the number of operations that can be undone. There is only one undo depth value per root container. Subcontainers do not have their own separate values.

LEADTOOLS provides a number of methods and properties for handling the undo capabilities.

The undo depth for the automation handle is contained in the AnnUndoDepth property.

The AnnUndo method undoes the last automation operation performed, including changes made to object properties.

Generally, operations are undone one operation at a time. If the last operation performed cut several objects from a container, undoing that operation would return the objects to the container. Occasionally, it may be best to group several operations, such as object additions or property changes, together so that calling AnnUndo undoes the whole group of operations and not just the last operation performed. This can be accomplished by:

1.

Setting the number of undo actions that can take place using the AnnUndoDepth property. This property defaults to 5.

2.

Calling the AnnAddUndoNode method to add an undo node to the automation object.

3.

Disabling the undo feature by setting the AnnUndoEnable property to FALSE.

4.

Performing the operations or changes to be combined into one undo.

5.

Re-enabling the undo feature by setting the AnnUndoEnable property to TRUE.

Now, all the operations can be undone with one call to the AnnUndo method instead of several calls to the AnnUndo method.