Search code examples
.netvisual-studiovisual-studio-2010f#add-in

How do I attach my Visual Studio Add-in window to a tab programmatically?


I'm creating a small addin in the hopes of making it fun and easy to play with graphics in Visual Studio. There has been one small annoyance though, I can't seem to figure out how to attach my newly created window to the tab bar.

It's all F#, but the solution should be just a couple of function calls so please feel free to use C# or VB in your answer.

type WindowManager(applicationObject: DTE2, addInInstance: AddIn) = 
    member this.CreateWindow(control: Type, caption) = 
        let windowInterface = applicationObject.Windows :?> Windows2
        let tempObj = ref null
        let assemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location
        let className = control.FullName
        let instanceGuid = System.Guid.NewGuid().ToString("B")
        let toolWindow = windowInterface.CreateToolWindow2( addInInstance, assemblyLocation, className, caption, instanceGuid, tempObj)
        toolWindow.Visible <- true

I think I just need to link it to something in the applicationObject. The only problem is what.


Solution

  • I seem to have figured it out:

    toolWindow.Linkable <- false
    toolWindow.WindowState <- vsWindowState.vsWindowStateMaximize
    toolWindow.Visible <- true