Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi experts,

I'm very much newbie to VS Addins.

Although, I subscribed to DocumentEvent.DocumentOpened. But additionally, I need to detect if already opened document got focus and I will read its contents then.

How to get its focused state?

Thanks

Farrukh
Posted

1 solution

Fortunately, after playing some sample code, I've got what I want. Its actually EnvDTE.WindowEvents.

In VS IDE, every Code Document is also a Window. And it has the Focus event: WindowActivated. Here is my delegate to subscribe for this event:
C#
WinEvents.WindowActivated += new _dispWindowEvents_WindowActivatedEventHandler(WinEvents_WindowActivated);

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



Regards
Farrukh
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900