Export (0) Print
Expand All

How to: Change Window Characteristics

Windows in Visual Studio are represented in the automation model by the Window2 object. By using its members, you can manipulate the characteristics of a window, such as its width, height, visibility, and so forth. By using the Window2 collection, you can create a linked window, which is comprised of two or more tool windows docked together. Their members also enable you to dock additional windows to or undock additional windows from the frame.


The windows to be linked must be visible. If either window is hidden, you get an exception. You can display windows by using the Visible property.

The Windows2 collection also enables you to create your own tool windows. For more information, see How to: Create and Control Tool Windows.


The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. These procedures were developed with the General Development Settings active. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

The following examples demonstrate how to reference and use the various members of the automation model to manipulate tool windows. They create a linked tool window and insert two Visual Studio tool windows, namely Solution Explorer and the Output window, linking them together. They also show how to size and undock tool windows. For more information about how to run the sample code in an Add-in, see How to: Compile and Run the Automation Object Model Code Examples.

Caution noteCaution:

Running this example will change your current Visual Studio tool window layout.

public void OnConnection(object application, ext_ConnectMode 
  connectMode, object addInInst, ref Array custom)
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;

public void chgWindow(DTE2 dte)
    // Create variables for the various tool windows.
    EnvDTE80.Window2 winFrame;
    Window win1 = 
    Window win2 = dte.Windows.Item(Constants.vsWindowKindOutput);
    Window win3 = 

    // Create a linked window frame and dock Solution 
    // Explorer and the Ouput window together inside it.
    winFrame = (Window2)dte.Windows.CreateLinkedWindowFrame(win1, win2, 
    System.Windows.Forms.MessageBox.Show("Total number of windows in 
      the linked window frame: " + winFrame.LinkedWindows.Count);

    // Add another tool window, the Command window, to the frame 
    // with the other two.
    System.Windows.Forms.MessageBox.Show("Total number of windows in 
      the linked window frame: " + winFrame.LinkedWindows.Count);

    // Resize the entire linked window frame.
    winFrame.Width = 500;
    winFrame.Height = 600;
    System.Windows.Forms.MessageBox.Show("Frame height and width 
      changed. Now changing Command window height.");

    // Resize the height of the Command window.
    winFrame.LinkedWindows.Item(3).Height = 800;
    System.Windows.Forms.MessageBox.Show("Now undocking the Command 
      window from the frame.");

    // Undock the Command window from the frame.

Community Additions

© 2015 Microsoft