-->

Double-click event on a Visio shape

2019-08-02 21:02发布

问题:

How can I catch a double click event on a Visio shape? I would like to display some properties when the user double-click on the shape but to do so I first need to catch this event.

Any suggestion is very welcome. Thanks a lot.

P.S. I use C# + Visio 2007 SDK.

回答1:

I'm not sure there is a double click event available in the Visio API. I've never seen one. You can, however, set up a shape to report a double click to some code procedure, through the shapesheet window. To get there, select a shape, and go to Window->Show Shapesheet, and you'll see a spreadsheet-looking window that describes pretty much everything about the shape.

There should be an Events section (if not right click in the gray area and select "insert section" and pick it), where you can specify a shapesheet function in the EventDblClick cell to get called on double clicking that shape. You'd use something like CALLTHIS or RUNADDON to get to the code you want to execute.

Unfortunately, doing it this way requires you to set up the shape(s) you want to watch before you try to watch them. You can set the EventDblClick cell formula programmatically, so you could do that on opening your addin. Or you could set that up manually and provide the shapes you want to watch through a stencil.

You could also watch for the MouseUp event on the active Visio.Window object, and if there are two mouseups in some amount of time, count that as a double click...

There may be other ways, but I don't know of them.



标签: c# visio