How to get the current editor in visual studio 2008 using c #

I am writing an addin for VS 2008 in C # and I want to know what kind of "scope" editor / constructor is open (for example VS Editor / VB Editor). Can I catch the event where the area changes

+1


source to share


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







All Articles