locked
VSPackage + VS2010: Visibilty of ToolWindows in DebugMode RRS feed

  • Question

  • Hello,

    I have a problem with the behaviour of the toolwindows.
    I made a tool window (My Explorer) that compares to the Server-Explorer Window.
    When the user clicks on an element in (My Explorer) a new window (Detail Window) should open,
    in the same place as regular source code windows does

    I use a toolwindow for this (CodeViewToolWindow).

    In the VSPackage I defined

     [ProvideToolWindow(typeof(CodeViewToolWindow), Style = VsDockStyle.MDI, Orientation = ToolWindowOrientation.Bottom, Transient = true)]

    and here is the creation code

     

     int CodeWindowCount = 1;
      public void ShowCode(DbSettings db, DB2Member member)
      {
       ToolWindowPane window = this.FindToolWindow(typeof(CodeViewToolWindow), CodeWindowCount, true);
       CodeWindowCount++;
       if ((null == window) || (null == window.Frame))
       {
         // ... errormessage here ...
       }
       CodeViewToolWindow tw = window as CodeViewToolWindow;
       if (tw == null) return;
       IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
       Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
       // ...
      }
    
    The result is ok, as a new (CodeViewToolWindow) shows up in the same place as the source code windows, and also when I restart Visual Studio the old CodeViewToolWindows are NOT restored.

     

    My only problem is the switch to debugmode. The window hide when I start debugging and show up when debugging ended.
    I know that this is the desired behaviour for a typical tool window, but in my case, it should stay visible as a regular source code windows does ...

    What must I add to achieve this?


    best regards Stephan Hartmann ML-Software GmbH

    Monday, August 1, 2011 1:42 AM

Answers

  • In Visual Studio 2010 there is a new frame creation flag for this called __VSCREATETOOLWIN2.CTW_fDocumentLikeTool.    This flag will imply that the tool is only permitted in the document well, is transient, is not context visible, is destroyed when closed, and will maintain its position when you transition between layout modes like from design to debug or full screen.   

     

    There isn’t a convenient attribute for this so you will need to add it yourself.    In your tool code in an overridden OnToolWindowCreated add the following…

     

    public override void OnToolWindowCreated()

    {

        base.OnToolWindowCreated();

     

        IVsWindowFrame windowFrame = Frame as IVsWindowFrame;

        object varFlags;

        windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_CreateToolWinFlags, out varFlags);

        int flags = (int)varFlags | (int)__VSCREATETOOLWIN2.CTW_fDocumentLikeTool;

        windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_CreateToolWinFlags, flags);

    }

    Monday, August 1, 2011 6:45 PM

All replies

  • In Visual Studio 2010 there is a new frame creation flag for this called __VSCREATETOOLWIN2.CTW_fDocumentLikeTool.    This flag will imply that the tool is only permitted in the document well, is transient, is not context visible, is destroyed when closed, and will maintain its position when you transition between layout modes like from design to debug or full screen.   

     

    There isn’t a convenient attribute for this so you will need to add it yourself.    In your tool code in an overridden OnToolWindowCreated add the following…

     

    public override void OnToolWindowCreated()

    {

        base.OnToolWindowCreated();

     

        IVsWindowFrame windowFrame = Frame as IVsWindowFrame;

        object varFlags;

        windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_CreateToolWinFlags, out varFlags);

        int flags = (int)varFlags | (int)__VSCREATETOOLWIN2.CTW_fDocumentLikeTool;

        windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_CreateToolWinFlags, flags);

    }

    Monday, August 1, 2011 6:45 PM
  • works like a charm

    thanks a lot  


    best regards Stephan Hartmann ML-Software GmbH
    Wednesday, August 3, 2011 7:14 PM