How to get the current editor in visual studio 2008 using c #
1 answer
I can't try it right now, so take it with a grain of salt:
public class Connect : IDTExtensibility2, IDTCommandTarget
{
public void OnConnection( object application, ext_ConnectMode connectMode,
object addInInst, ref Array custom )
{
_applicationObject = ( DTE2 ) application;
_applicationObject.Events.SelectionEvents.OnChange += SelectionEvents_OnChange;
}
void SelectionEvents_OnChange()
{
vsWindowType type = _applicationObject.ActiveWindow.Type;
// switch (type) { ... }
}
}
EDIT: Maybe Event Selection is not what you want. I don't know if there is some other event that you can hook. Anyway the line
vsWindowType type = _applicationObject.ActiveWindow.Type;
indicates the type of the active window.
+1
source to share