Dev Luv: Using the Double-click Event in Visio


The double-click event in Visio is driven by the Shapesheet. To prototype how this works, drop a shape onto a Visio page and go into that shape’s Shapesheet. Scroll down to the Event section in the Shapesheet (it’s towards the bottom) and look for the EventDblClick cell. By default, shapes have the OPENTEXTWIN() formula, which opens up an empty text window when you double-click a shape. Add a Shapesheet formula to that cell, like HYPERLINK. You can use GOTOPAGE or HYPERLINK to link to a URL, another Visio page or shape in the same document, or a page or shape in another Visio document. For this prototype, add the following syntax to the cell:


=HYPERLINK(http://blogs.msdn.com/mailant)

Now, when you double-click the shape, it will open a new IE window with my blog in it.

 

If you want to do this programmatically, you can use the Shape.CellsSRC property to get the specific EventDblClick cell and then use FormulaU to set the formula. The Visio SDK contains C#, VB, and VB.NET samples on programmatically setting formulas; check the Code Librarian sample database and look in the Custom Properties section. You can use SetFormulas if you are setting multiple formulas. Search the Code Librarian for SetFormulas and you’ll get some samples for its use as well.

 

There is no specific double-click event object. If you don’t want to use the Visio Shapesheet-based double-click functionality, you can build on the Visio 2003 mouse events that I talked about earlier in the week. You’ll need to write some code to track whether a sequence of mouse events yields a "double-click." You’ll have to use the x,y  coordinates returned by the Visio mouse events and a time-based measurement using system timing functions like Win32's GetTickCount or VB's Timer function. If you want to replicate the HYPERLINK functionality that we used in the prototype, use the Document.FollowHyperlink method in the Visio OM. (See the my earlier post Dev Luv: Top Ten Things to Know Before Using the Visio 2003 ActiveX Control if you’re thinking about using FollowHyperlink for a control application.)

 

 -- Mai-lan

 

This posting is provided "AS IS" with no warranties, and confers no rights

Skip to main content