Geeks With Blogs

News

 Subscribe



Utkarsh Shigihalli Microsoft MVP and Microsoft ALM Ranger writing on Visual Studio Extensibility, ALM and .NET

In this blog post we will see how to listen to toolwindow events. I am going to assume that you already know how to create toolwindows.

Tool windows are most common and widely used while you to work inside Visual Studio. If you are wondering what are tool windows inside Visual Studio, think about Solution Explorer, Immediate Window, Output Window and even Property Window. These windows are most flexible allowing you to dock, auto-hide and even support multiple monitors.

toolwindow

If you are Visual Studio extension developer, sooner or later you will be required to create tool windows in your extensions, because they integrate seamlessly inside Visual Studio. 

Visual Studio SDK provides IVsWindowFrameNotify3 interface which needs to be implemented by your ToolWindowPane class. The interface IVsWindowFrameNotify3 provides methods to track close, change in dock state etc.

Note: Visual Studio fires OnClose event but does not actually close it. Instead it just hides it from the view. The actual Close event is a overriden method which is fired only when Visual Studio instance is closed.

 

[Guid("6912BAC8-BD13-4B64-A675-D83902A63077")]
public class MyToolWindow : ToolWindowPane, IVsWindowFrameNotify3
{
    /// <summary>
    /// Standard constructor for the tool window.
    /// </summary>
    public MyToolWindow(): base(null)
    {
    }

    public int OnClose(ref uint pgrfSaveOptions)
    {
        return Microsoft.VisualStudio.VSConstants.S_OK;
    }

    public int OnDockableChange(int fDockable, int x, int y, int w, int h)
    {
        return Microsoft.VisualStudio.VSConstants.S_OK;
    }

    public int OnMove(int x, int y, int w, int h)
    {
        return Microsoft.VisualStudio.VSConstants.S_OK;
    }

    public int OnShow(int fShow)
    {
        return Microsoft.VisualStudio.VSConstants.S_OK;
    }

    public int OnSize(int x, int y, int w, int h)
    {
        return Microsoft.VisualStudio.VSConstants.S_OK;
    }
}
Posted on Saturday, August 3, 2013 12:58 PM C# , .NET , Visual Studio Integrate , VSX | Back to top


Comments on this post: Listening to tool window events in Visual Studio

comments powered by Disqus

Copyright © Utkarsh Shigihalli | Powered by: GeeksWithBlogs.net