Visio:捕获切换 window/document 事件

Visio: catch switching window/document event

我为 Visio 开发了一个加载项,但在捕获时遇到了一些问题 某些事件。我有一个自定义功能区用于我的加载项以及我已经可以做的事情, 启用或禁用 (show/hide) 它基于文档。

但是现在我想打开多个文档,然后切换到 如果应启用或禁用功能区,则为另一个文档。但是我似乎无法为此找到合适的事件代码。我尝试了以下代码但没有成功:
- 页面已更改
- 窗口已更改
- BeforeWindowPageTurn
- WindowTurnedToPage

具体来说,我想做的是在一个文档失去焦点而另一个文档获得焦点时捕获事件。

您可以收听 Application.WindowActivated event and then in the handler, inspect the ActiveDocument or the window.Document property (in the eventargs) to decide whether it is a document that you're interested in. You might also want to listen to DocumentCreated and DocumentOpened(在应用程序上),并且只有在您知道该应用程序可能正在处理您的一个文档后才开始收听 window 事件。