在Visio加载项项目中捕获WindowTurnedToPage事件 [英] Catch WindowTurnedToPage Event in a Visio AddIn project

查看:137
本文介绍了在Visio加载项项目中捕获WindowTurnedToPage事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户在visio窗口的页面之间交换时,我正在尝试执行一些代码.因此,我尝试捕获WindowTurnedToPage事件,但它根本不起作用. 可以发现他家人的其他事件,并且他们应该在适当的时候做出响应.但是WindowTurnedToPage和BeforeWindowPageTurn没有响应.

I'm trying to execute some code when the user swap between the pages of a visio window. So i tried to catch the WindowTurnedToPage event, but it simply don't work. Other events from his family can be catched, and they respond when they should. But WindowTurnedToPage and BeforeWindowPageTurn don't respond.

private void InternalStartup()
    {
        this.Startup += new System.EventHandler(ThisAddIn_Startup);
        this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
        Application.Window.WindowTurnedToPage +=  new Visio.EWindow_WindowTurnedToPageEventHandler(Window_WindowTurnedToPage);
    }

    private void Window_WindowTurnedToPage(Visio.Window Window)
    {
        MessageBox.Show("Page changed");
    }

请提供任何帮助,我们将不胜感激.赶上Page Turn事件的理由是什么?

Please any help will be certain appreciate. What shoud ito to catch the Page Turn event?

推荐答案

我认为您可以使用Application.WindowTurnedToPage.

这将触发应用程序中的所有页面切换.

This will trigger for all page switches in the application.

您的第一个版本Application.Window.WindowTurnedToPage无法正常工作,因为Application.Window是主应用程序窗口(即框架窗口-不是绘图窗口),因此它没有任何页面.

Your first version, Application.Window.WindowTurnedToPage did not work because Application.Window is main application window (i.e. frame window - not a drawing window), so it does not have any pages.

第二个版本Application.ActiveWindow.WindowTurnedToPage可能存在缺陷-它会将您的事件绑定到执行代码时处于活动状态的窗口.如果稍后再打开另一个文件,您的代码将不会触发该文件窗口的事件.

The second version Application.ActiveWindow.WindowTurnedToPage may have a flaw - it will bind your event to the window that was active when you executed your code. If later on, you open another file, your code will not trigger event for that file's window.

但是,如果您只想捕获单个窗口的页面切换,那就可以了.

However, if you want to capture page switches only for a single window, that might be okay.

这篇关于在Visio加载项项目中捕获WindowTurnedToPage事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆