Undoing and Redoing Automation Operations

The LEADTOOLS Automation features include an Undo/Redo engine for undoing and redoing automation operations. The undo level determines the number of operations that can be undone. For each undo that is performed, a redo operation can be performed. The undo level set for an automation handle applies to every container associated with that automation handle. For example, if an automation handle has four associated containers in four different windows, each container can have a maximum of 16 operations undone sequentially.

LEADTOOLS provides a number of functions for handling the undo/redo capabilities.

To determine the current undo level of the automation handle, call L_AutGetUndoLevel. The default value is DEF_AUTOMATION_UNDO_LEVEL [16]. To set a new undo level for the automation handle, call L_AutSetUndoLevel.

To determine whether the last automation operation performed can be undone or redone, use L_AutCanUndo and L_AutCanRedo respectively.

L_AutUndo undoes the last automation operation performed, while L_AutRedo redoes the last automation operation undone.

The following example determines whether the last operation performed in the active automation container can be undone. If it can be undone, then L_AutUndo is called.

/* This example shows how simple it is to undo the last automation operation */ 
L_INT AutomationUndoTest(pAUTOMATIONHANDLE pAutomation) 
{ 
   if (SUCCESS == L_AutIsValid(pAutomation)) /* check the validity of the automation handle */ 
   { 
      L_BOOL fCanUndo; 
      /* Query the ability of undoing */ 
      L_AutCanUndo(pAutomation, &fCanUndo); 
      if (fCanUndo) 
      { 
         /* undo the last automation operation */ 
         L_AutUndo(pAutomation, 0); 
      } 
      return SUCCESS; 
   } 
   else 
   { 
      return FAILURE; 
   } 
} 

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 together so that calling L_AutUndo undoes the whole group of operations and not just the last operation performed. This can be accomplished using the following steps:

1.

Call L_AutAddUndoNode to add an undo node to the automation handle.

2.

Disable the undo feature by calling L_AutSetUndoEnabled(pAutomation, FALSE).

3.

Perform the operations to be combined into one undo.

4.

Re-enable the undo feature by calling L_AutSetUndoEnabled (pAutomation, TRUE).

When L_AutUndo is called for this node, all of the combined operations will be undone.

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Container and Automation C API Help