我是 VS Addins 的新手。
不过,我订阅了 DocumentEvent.DocumentOpened。但另外,我需要检测已打开的文档是否获得焦点,然后我将读取其内容。
如何获取其聚焦状态?
谢谢
法鲁克
最佳答案
幸运的是,在播放了一些示例代码之后,我得到了我想要的东西。它实际上是 EnvDTE.WindowEvents。
在 VS IDE 中,每个代码文档也是一个窗口。它有 Focus 事件:WindowActivated。这是我订阅此事件的代表:
WinEvents.WindowActivated += new _dispWindowEvents_WindowActivatedEventHandler(WinEvents_WindowActivated);
void WinEvents_WindowActivated(Window GotFocus, Window LostFocus)
{
Debug.WriteLine("GotFocus: " + GotFocus.Caption );
//throw new NotImplementedException();
}
最好的问候
法鲁克
关于visual-studio-addins - Visual Studio 加载项 : How to know if already opened document got focus?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10389395/