Reputation: 3088
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.
Upvotes: 1
Views: 212
Reputation: 3088
I seem to have figured it out:
toolWindow.Linkable <- false
toolWindow.WindowState <- vsWindowState.vsWindowStateMaximize
toolWindow.Visible <- true
Upvotes: 0
Reputation: 1406
My understanding is that the only way to control tool window position is to provide it via a VSPackage, not via AddIn (see http://msdn.microsoft.com/en-us/library/bb166406.aspx and http://msdn.microsoft.com/en-us/library/bb165452.aspx for more information).
I believe that the reason for this limitation is that positions of particular tool windows are user-controllable; even if you provide the tool window via VSPackage and specify its position via the registry magic as described in the above links, you still only control the location of a first appearance of a tool window. After that, the location will always come from wherever the user moved your toolwindow, and this is very deliberately non-overridable.
I might be missing some new VS2010 mechanisms though.
Upvotes: 1