Creating and Controlling Tool Windows
Windows in Visual Studio .NET fall into one of two categories: documents or tool windows. A document is one that is editable by the Code Editor. A tool window is one created by, and that can be manipulated by Visual Studio .NET automation. It can be a designer or a window such as the Task List or Toolbox.
In addition to manipulating existing Visual Studio .NET tool windows, you can also create your own using the CreateToolWindow method of the Windows collection. You can also use the LinkedWindows collection to link together or unlink tool windows in the IDE. For more information about this, see Changing Window Characteristics.
The exact procedure for creating tool windows depends upon the host language. For examples of how to create tool windows in Visual C++ .NET, Visual Basic .NET, and Visual C# .NET, see the ToolWindow samples for each language in the .../Automation/Samples directory on the Visual Studio .NET CDs or DVD.
Create Visual Basic .NET Tool Window Example
Below is an example of how to create a tool window in Visual Basic .NET.
Note The following code must be executed in an Add-in; it cannot be executed in a macro.
Public Sub OnConnection(ByVal application As Object, ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, ByRef custom() As Object) Implements IDTExtensibility2.OnConnection
Dim progid, guidposition As String
' The progid can be any valid progid. For example, you could substitute
' mediaplayer.mediaplayer.1 to place the Windows Media Player on a tool
' window.
progid = "VBToolWindowAddin.Control"
guidposition = "{99B7AA98-7ECD-4aa5-8ADB-96653DAE979D}"
applicationObject = CType(application, EnvDTE.DTE)
addInInstance = CType(addInInst, EnvDTE.AddIn)
windowToolWindow = applicationObject.Windows.CreateToolWindow(addInInstance, progid, "VB Tool Window", guidposition, objControl)
If Not windowToolWindow Is Nothing Then
windowToolWindow.Visible = True
End If
End Sub
See Also
Controlling Tools Options Settings | Changing Window Characteristics | Creating and Controlling Environment Windows | Creating Add-Ins and Wizards | Creating an Add-In | Creating a Wizard | Automation and Extensibility Reference | Automation Object Model Chart