【问题标题】:Visual Studio Addin: How to know if already opened document got focus?Visual Studio Addin:如何知道已经打开的文档是否获得焦点?
【发布时间】:2012-04-30 19:25:54
【问题描述】:

我是 VS Addins 的新手。

虽然,我订阅了 DocumentEvent.DocumentOpened。但另外,我需要检测已经打开的文档是否获得焦点,然后我会阅读它的内容。

如何获得它的焦点状态?

谢谢

法鲁克

【问题讨论】:

    标签: visual-studio-addins


    【解决方案1】:

    幸运的是,在播放了一些示例代码之后,我得到了我想要的。它实际上是 EnvDTE.WindowEvents。

    在 VS IDE 中,每个代码文档也是一个窗口。它有焦点事件:WindowActivated。这是我订阅此活动的代表:

    WinEvents.WindowActivated += new _dispWindowEvents_WindowActivatedEventHandler(WinEvents_WindowActivated);
    
    void WinEvents_WindowActivated(Window GotFocus, Window LostFocus)        
    {            
       Debug.WriteLine("GotFocus: " + GotFocus.Caption );            
       //throw new NotImplementedException();        
    }
    

    最好的问候

    法鲁克

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      • 2016-07-29
      • 1970-01-01
      • 1970-01-01
      • 2014-10-28
      相关资源
      最近更新 更多