Using Visio AddAdvise to add an event sink/handler to a Visio VSTO Add-in

Started by Visisthebest, August 11, 2023, 07:31:48 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Visisthebest

I am trying to use Visio AddAdvise to add an event sink/handler to the ActiveDocument, in this case from a Visio VSTO Add-in.

Ran in to an exception, posted my problem to Stackoverflow and Nikolay posted the solution. Problem solved really appreciate it Nikolay!

You can find the problem and solution here, Microsoft has not documented this in their Visio development documentation:
https://stackoverflow.com/questions/76879839/using-visio-addadvise-to-add-an-event-sink-handler-to-a-visio-vsto-add-in

Nikolay also thank you for the KeyboardEvent alternative, I still have to figure out how to capture for instance "CONTROL+L" with https://learn.microsoft.com/en-us/office/vba/api/visio.window.onkeystrokemessageforaddon

but good to know there is an alternative that does not require AddAdvise.
Visio 2021 Professional

Nikolay

There is an example of capturing (preprocessing) keys there, to make shortcuts work in forms (this one was specifically for a webbrowser shorcuts, but I think the idea may be extended to other controls)

https://github.com/nbelyh/VisioHtmlSidebar/blob/2e99e9319c5d4ca05380fb343c3ec18745274cac/Addin/ShortcutManager.cs

Usage here:

https://github.com/nbelyh/VisioHtmlSidebar/blob/2e99e9319c5d4ca05380fb343c3ec18745274cac/Addin/ThisAddIn.cs

It is C# but maybe not much of a difference

Visisthebest

Thank you Nikolay that looks like a good solution for capturing shortcut key presses as well!

Converting the code to vb.net shouldn't be too hard, still in vb.net holding out hope for a matured release of TwinBasic at some point in 2024.

With TwinBasic we can get rid of the .NET COM interop altogether!
Visio 2021 Professional