Visio 2003 introduced mouse and keyboard events into the Visio object model. These events are not shape-specific. The events return the x and y co-ordinates (in internal Visio units) for where the event occurred on the window or drawing page. The implementation lets you respond to mouse events for any part of the drawing window or page – it can be the user clicking on a blank area of your diagram (in case you want to present an error message) or on a shape (to show a custom right-click menu).
If you’re trying to respond to a click event for a shape, you’ll need to find the shape from the x and y coordinates returned by the event. Use the SpatialSearch property on the Page object. You’ll need to pass in the following parameters: x (returned from the event), y (returned from the event), visSpatialContainedIn (flag that asks for shapes contained in other shapes), 0.001 (a very small tolerance relative to the size of the shape), visSpatialFrontToBack (another flag that orders the shapes returned from back to front). The property returns a display-list-ordered Selection object that contains all of the shapes (can be one or more) that contain the point x, y within the tolerance. Keep your tolerance small relative to the size of the shape, and your Selection object is more likely to return the single shape that you care about rather than multiple shapes.
One thing to remember: If you are displaying a custom dialog as a result of the mouse click in the ActiveX control context, you will have to map the Visio co-ordinates to Windows co-ordinates. The point of origin (0,0) in Visio lives in the bottom left corner of the drawing page. Check the SDK ActiveX control sample for a re-usable method that does the conversion for you.
This posting is provided "AS IS" with no warranties, and confers no rights