I am writing a Visual Studio 2008 extension. I want to be notified every time DTE.ActiveDocument changes, so I can update something in a custom panel which performs a similar feature to solution explorer. I have yet to find any event which occurs when this happens. Is there such an event?
Concretely, I'm looking for something like:
var dte = GetService(typeof(EnvDTE._DTE)) as EnvDTE.DTE;
dte.Events.DTEEvents.ActiveDocumentChanged += s => {
// implies dte.ActiveDocument has changed value
}
I belive you are looking for this event
_applicationObject.Events.WindowEvents.WindowActivated
check GotFocus.Document == null
if you only interested in Document activation changes
Hope this helps
You can also implement IVsRunningDocTableEvents
, register yourself as a listener, and then the OnBeforeDocumentWindowShow
method will be called before a document is switched to.
class RdtEvents : IVsRunningDocTableEvents
{
RdtEvents()
{
var rdt = Package.GetGlobalService(typeof(SVsRunningDocumentTable));
uint evtCookie;
rdt.AdviseRunningDocTableEvents(this, out evtCookie);
}
// ...
int IVsRunningDocTableEvents.OnBeforeDocumentWindowShow(uint docCookie, int fFirstShow, IVsWindowFrame pFrame)
{
// ...
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With