Visual Studio Developer Center > Visual Studio Forums > Visual Studio Extensibility > AddIn: Adding a window to an existing frame (CreateLinkedWindowFrame)
Ask a questionAsk a question
 

AnswerAddIn: Adding a window to an existing frame (CreateLinkedWindowFrame)

  • Monday, November 02, 2009 10:02 PMvaucouleur Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code

    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:

    Window2 frame = (Window2)dte.Windows.CreateLinkedWindowFrame(solutionExplorerWindow, newWindow, vsLinkedWindowType.vsLinkedWindowTypeTabbed);
    
    
    
    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).

    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

  • Friday, November 06, 2009 1:22 AMJeff Robison -- MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    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

All Replies

  • Tuesday, November 03, 2009 11:35 PMvaucouleur Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code

    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 ?


  • Thursday, November 05, 2009 1:26 AMJeff Robison -- MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    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

  • Thursday, November 05, 2009 11:04 PMvaucouleur Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    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.
  • Friday, November 06, 2009 1:22 AMJeff Robison -- MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    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

  • Friday, November 06, 2009 6:47 PMvaucouleur Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Ok, thanks Jeff.