![]() |
Visio 2002 Developer's Survival Pack Tools and Samples |
Chapter 18: Events and Notifications | |
![]() ![]() |
A collection of samples pertaining to events and notifications of various kinds. It may be very informative to try these samples in conjunction with the Events Browser.
Filename | Description |
SimplePageWithEvent.vdx | Open the VBA window and inspect the ThisDocument module. Run the PageEvents_Init procedure to initialize events. (To do this, place cursor in the procedure and click the Run arrow.) Now drop shapes on the drawing page (for example using the Rectangle tool). Observe the reports written to the VBA Immediate window by the APage_ShapeAdded procedure. |
EventListAddRunAddon.vdx | Before running this sample, you will need to perform the
simple installation of the ReflectArgs sample application. See the sample
folder for Chapter 21.
Open the VBA window and inspect the ThisDocument module. Run the HookupAShape procedure to set up an event for cell changes on the one shape on the drawing. Now, on the drawing select the one sample shape and try changing something that will affect one or more cells, such as adjusting the width. Observe how this causes Visio to call the Addon executable app specified in HookupAShape, possibly multiple times. |
SimpleEventListAdd.vdx | Basically the same demo as EventListRunAddon, except that here the Hookup procedure creates an event for Application. |
SimpleEventSink.vdx | Open the VBA window and inspect the ThisDocument module. Run the HookupEvent procedure to set up an event on Application for cell changes in any drawing. Now, on the drawing select the one sample shape and try changing something that will affect one or more cells, such as adjusting the width. Observe how this causes Visio to call ASimpleEventSink.IVisEventProc_VisEventProc, which writes messages to the VBA Immediate window. |
WithEventsUsingClassModule.vdx | This sample demonstrates several topics:
When you open this document, (assuming you enable macros) events will be set up automatically. At that point you can adjust the width or height of the sample shape, and observe this firing CShapeEventCatcher.AShape_CellChanged which writes reports to the Immediate window. |
EventSinkForwarding.vdx | A variation on the EventSink theme, which can make for
tidier code. In previous EventSink examples, the actual
event-handling code is placed in the EventSink class itself. The problem
with this is that when handling a variety of events on a variety of
objects, a project can end up with a proliferation of EventSink classes
which are hard to maintain.
In the approach demonstrated here, only a single generic CEventSinkForwarder class is needed. Objects created from this class forward ("delegate") event calls to their respective owner modules. This allows the specific event-response code to reside in the same module that created the event sink in the first place -- potentially much more orderly. |
EventSinkWithFilters.vdx | As with several of the samples above, start by opening the
VBA window and ThisDocument module, and run the HookupEvent procedure.
Verify that this did something useful by resizing the one shape on the
drawing, and observe the reports to the Immediate window. Now try running
the various SetEventFilterXxx procedures, and observe the events which now
do or don't result in event reports. You'll have to inspect each
SetEventFilter procedure to see which events are included or excluded in
each case. You can also try the corresponding procedures to read the event
filters.
The Events Browser is especially useful with this sample. Note that the event in this sample is on Application, so you can set Events Browser to survey only down to the level of Application, which is very quick. |
Article Created: 2001-06-01 Last edit: Last edit: 01-06-30 Graham Wideman
Go to: DiagramAntics.com