Programatically closing a Toolwindow created using CreateToolWindow2

I've got a dockable addin that I've created and want to be able to programatically autohide it when the action is complete.
[131 byte] By [spotty] at [2007-12-16]
# 1
The following should work:

EnvDTE80.Windows2 toolWins;

EnvDTE.Window toolWin;

toolWins = (Windows2)_applicationObject.Windows;

// Create the new tool window, adding your user control.

toolWin = toolWins.CreateToolWindow2(_addInInstance,

asmPath, ctlProgID, "MyNewToolwindow", guidStr,

ref objTemp);

// The tool window must be visible before you do anything

// with it, or you will get an error.

if (toolWins == null)

{

toolWin.Visible = true;

}

// Uncomment the code below to set the new tool window's

// height and width, and to close it.

// System.Windows.Forms.MessageBox.Show("Setting the height

// to 500 and width to 400...");

// toolWin.Height = 500;

// toolWin.Width = 400;

// System.Windows.Forms.MessageBox.Show

// ("Closing the tool window...");

// toolWin.Close(vsSaveChanges.vsSaveChangesNo);

SirkkuWillieMSFT at 2007-9-9 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...

Visual Studio

Site Classified