Chapter 25, Using the Visio Undo Manager in Your Program

Chapter 25, Using the Visio Undo Manager in Your Program

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Changes to a Microsoft® Visio® document can occur in one of two ways: through a user action in the user interface, or through an Automation program. A user can undo or redo the change in the user interface just as you can undo or redo changes in your program using the Undo or Redo method. Every Visio instance contains one Undo manager that tracks undoable and redoable actions across the application. An undoable action can be anything that modifies or changes the state of a document. The queues of undoable and redoable actions are called stacks.

The Visio Undo manager provides the flexibility to handle undoable actions as discrete actions, or to consolidate multiple undoable actions into a single unit that gets managed on the undo and redo stacks as a single undoable action. To do this, the Visio engine creates an undoscope.

Additionally, if your solution maintains a parallel or shadow model that represents data associated with the shapes in your drawing, you can create undo units to place on the Visio Undo manager to keep your data and drawings synchronized. Undo units contain the actions needed to undo or redo changes to a document.

Note In versions earlier than Visio 2000, each individual action performed in an add-on was a single undoable action in Visio. If a user chose Undo, only the most recent action was undone.

Beginning with Visio 2000, the sequence of actions performed by an add-on that is invoked from Visio is automatically managed as a single undoable action. If a user chooses Undo, all Visio-specific actions performed in the add-on are reversed. For details, see How the Visio Undo Manager Works with an Add-on later in this chapter.

In this chapter…

The Visio Undo Manager

Creating Undo Scopes in Your Add-on

Creating Undo Units

Creating an Undo Unit that Maintains Non-Visio Data: an Example