AddIn: Adding a window to an existing frame (CreateLinkedWindowFrame)
- Context: AddIn, VS2005, VS2008, VS2010.Hi,I am trying to add a window to an *existing* frame, such as for example the frame that contains the solution explorer. Continuing on this specific example, the goal is to add this new window close to the solution explorer, without changing the docking of the frame that contains the solution explorer.As mentioned at various places, one can use the following code to link the solution explorer window and the new window together:But this does not work, or at least is is not enough, since it will leave the two windows floating around (and we do not want to change the location/docking of the solution explorer).
Window2 frame = (Window2)dte.Windows.CreateLinkedWindowFrame(solutionExplorerWindow, newWindow, vsLinkedWindowType.vsLinkedWindowTypeTabbed);
The only related API seems to be:existingFrame.LinkedWindows.Add(frame);
.. but this does not help much since we need to find the existing "parent" frame of the solution explorer (existingFrame in the code above), which does not seems accessible.Any ideas ?Sebastien.
Answers
Hello Sebastien,
I believe that the documentation for VSSETFRAMEPOS.SFP_fDockBottom is incorrect; I believe it should also be marked obsolete. I will confirm this and file a bug to get it fixed.
I misspoke when I said SetFramePos could be used to toggle the docked state of a tool window. As the documentation for VSSETFRAMEPOS states, neither VSSETFRAMEPOS.SFP_fTab nor VSSETFRAMEPOS.SFP_fFloat can be used with SetFramePos. The easiest way to toggle the docked state of a tool window is via the Window.IsFloating property.
As you surmise, VS uses a method other than SetFramePos to reposition windows in response to user actions. This is unfortunate.
Regards,
Jeff
- Proposed As Answer byJeff Robison -- MSFT Friday, November 06, 2009 1:23 AM
- Marked As Answer byvaucouleur Friday, November 06, 2009 6:47 PM
All Replies
- The following code does not work neither, it will dock the window outside of the "solution explorer frame":
Window2 frame = (Window2) solutionExplorerWindow.LinkedWindowFrame; frame.LinkedWindows.Add(windowToDock);
I kept searching but found no obvious way to proceed, which is surprising since docking a Window2 "close to the solution explorer without undocking the solution explorer" seems to be, a priori, an common requirement. Did I miss something obvious ? Is it something that can only be done with a package ?- Unproposed As Answer byNathan Halstead [MSFT]ModeratorThursday, November 05, 2009 8:03 PM
- Proposed As Answer byJeff Robison -- MSFT Thursday, November 05, 2009 1:24 AM
Unfortunately, DTE doesn’t support exactly what you’re trying to do.
The IVsWindowFrame interface has a SetFramePos method that will allow you to change a window’s docked/floating state and change its size and position if it’s floating. It also should allow you place your window as you desire by using the Solution Explorer’s GUID as its guidRelativeTo parameter and appropriate VSSETFRAMEPOS flags, but that support was never implemented.
If you’re writing a package with a tool window you can specify the tool window’s initial position in its display configuration, but because of the limitation in IVsWindowFrame::SetWindowPos you cannot alter its docking location programmatically.
Regards,Jeff Robison
- Unproposed As Answer byvaucouleur Thursday, November 05, 2009 11:04 PM
- Proposed As Answer byNathan Halstead [MSFT]ModeratorThursday, November 05, 2009 2:09 AM
- Jeff,I tried using SetFramePos on a IVsWindowFrame as you suggested. I tried both VSSETFRAMEPOS.SFP_fTabNext, and VSSETFRAMEPOS.SFP_fDockBottom, and both method invocations returned E_NOTIMPL (currently using VStudio 2008). The former is marked as obsolete, but the latter should be implemented if one refer to the following documentation:The other VSSETFRAMEPOS are either obsolete, or not usable in the context of SetFramePos method call, or not relevant for docking (for example SFP_fMove).I am puzzled because at the "graphical user interface level", VStudio do allow for such kind of docking (obviously), so there should be some way to implement this. Is it a case where VStudio uses some "internal API" that are not available for packages ?Thanks,Sebastien.
Hello Sebastien,
I believe that the documentation for VSSETFRAMEPOS.SFP_fDockBottom is incorrect; I believe it should also be marked obsolete. I will confirm this and file a bug to get it fixed.
I misspoke when I said SetFramePos could be used to toggle the docked state of a tool window. As the documentation for VSSETFRAMEPOS states, neither VSSETFRAMEPOS.SFP_fTab nor VSSETFRAMEPOS.SFP_fFloat can be used with SetFramePos. The easiest way to toggle the docked state of a tool window is via the Window.IsFloating property.
As you surmise, VS uses a method other than SetFramePos to reposition windows in response to user actions. This is unfortunate.
Regards,
Jeff
- Proposed As Answer byJeff Robison -- MSFT Friday, November 06, 2009 1:23 AM
- Marked As Answer byvaucouleur Friday, November 06, 2009 6:47 PM
- Ok, thanks Jeff.


