VSX - set the initial position of ToolWindowPanes for docking

I am creating a Visual Studio package that provides a tool window, and I am trying to make sure that it appears docked to the left edge of the main Visual Studio window when the package is loaded first.

[ProvideToolWindow(typeof(MyToolWindow), Orientation = ToolWindowOrientation.Left, Style=VsDockStyle.Linked, Window=EnvDTE.Constants.vsWindowKindLinkedWindowFrame)])] [ProvideToolWindowVisibility(typeof(MyToolWindow), VSConstants.UICONTEXT.NoSolution_string)] public class MyPackage : Package { ... 

I tried the many options above, but the best I managed to achieve was to attach the window to the base - and even then it continues to reinstall every time the package is reloaded, and the position of the user window is not saved.

How can I indicate that my window pane is initially docked to the left of the main window?

+4
source share
4 answers

Setting items as VsDockStyle.Tabbed is supported, so you can connect to the toolbar tool window. But I assume that you have already thought about this, and this is not appropriate for your situation.

Although this is not a good solution, you can try a workaround.

  • Configure ProvideToolWindow with the Orientation and Window you want, but set the style for Float, since Linked is not supported (http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.vsdockstyle.aspx):

     [ProvideToolWindow(typeof(MyToolWindow), Style = VsDockStyle.Float, Orientation = ToolWindowOrientation.Left, Window = EnvDTE.Constants.vsWindowKindMainWindow)] 
  • At runtime, pin the tool window if you find it in a floating state:

     /// <summary> /// Docks the specified frame window if it is currently floating. /// </summary> /// <remarks> /// Works in VS2010, does not appear to work in VS2008. /// </remarks> /// <param name="frame">The frame.</param> private static void DockWindowIfFloating(IVsWindowFrame frame) { // Get the current tool window frame mode. object currentFrameMode; frame.GetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, out currentFrameMode); // If currently floating, switch to dock mode. if ((VSFRAMEMODE)currentFrameMode == VSFRAMEMODE.VSFM_Float) { frame.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, VSFRAMEMODE.VSFM_Dock); } } 

As I noticed in the comments - this seems to work only for VS2010 (and not VS2008).

Hope this helps, hacking as it is.

+2
source

If you want it to dock at the bottom by default with other windows, such as the Output Window, Error List, Search Results, etc., you can do this as follows:

 [ProvideToolWindow(typeof(ThePane), Orientation=ToolWindowOrientation.Right, Window=EnvDTE.Constants.vsWindowKindOutput, Style=VsDockStyle.Tabbed)] 

Orientation does not seem to matter, but it always seems to the left. But close enough for me.

+1
source

I don't know if this works, but you can try:

I looked in the registry for a hint where the SolutionExplorer toolbar is located and that the Window parameter contains "DocumentWell"

So you can try the following:

 [ProvideToolWindow(typeof(MyToolWindow), Orientation = ToolWindowOrientation.Right, Style=VsDockStyle.Tabbed, Window="DocumentWell")])] 

or

 Window=EnvDTE.Constants.vsWindowKindMainWindow 

Hope this helps,

Thomas.

0
source
 // Replace EnvDTE.Constants.vsWindowKindSolutionExplorer with the GUID you need. [ProvideToolWindow(typeof(IssuesWindow), Style = VsDockStyle.Tabbed, Window = EnvDTE.Constants.vsWindowKindSolutionExplorer)] 

This works fine in Visual Studio 2015. Tested in a virtual machine.

However, there is a limitation : The tool window only docked the first time the IDE starts with your extension. This is easy to verify using a virtual machine, as you are simply restoring the previous state. I assume that some registry value is written, and Visual Studio rather remembers the previous position of your tool window the next time, and does not use the default values ​​that you just specified above.

If someone wants, I think they could compare before / after the registry version and find these set values ​​and reset them manually next time / on demand.

0
source

Source: https://habr.com/ru/post/1345867/


All Articles