Visual Studio Addin: How do I know if a document has already opened focus?

I am very new to VS Addins.

Although I signed up for DocumentEvent.DocumentOpened. But, in addition, I need to determine if the document has already been opened, and I will read its contents.

How to get your focused state?

thank

Farrukh

+3
source share
1 answer

Fortunately, after I played the sample code, I have what I want. This is actually EnvDTE.WindowEvents.

In the VS IDE, each code document is also a window. And this is the Focus: WindowActivated event. Here is my delegate to sign up for this event:

WinEvents.WindowActivated += new _dispWindowEvents_WindowActivatedEventHandler(WinEvents_WindowActivated);

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

Regards

Farrukh

+2
source

All Articles