ToolWindows.GetToolWindow Method
Allows the user to retrieve a window by its title.
Namespace: EnvDTE80
Assembly: EnvDTE80 (in EnvDTE80.dll)
Syntax
'Declaration
Function GetToolWindow ( _
Name As String _
) As Object
Object GetToolWindow(
string Name
)
Object^ GetToolWindow(
String^ Name
)
abstract GetToolWindow :
Name:string -> Object
function GetToolWindow(
Name : String
) : Object
Parameters
Name
Type: System.StringThe title of the window to retrieve.
Return Value
Type: System.Object
A Window object.
Examples
This add-in obtains the caption of the Output Window, after retrieving it using the GetToolWindow method. For more information about how to run the automation examples, see How to: Compile and Run the Automation Object Model Code Examples.
Imports EnvDTE
Imports EnvDTE80
Public Sub OnConnection(ByVal application As Object, _
ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
ByRef custom As Array) Implements IDTExtensibility2.OnConnection
_applicationObject = CType(application, DTE2)
_addInInstance = CType(addInInst, AddIn)
GetToolWindow(_applicationObject)
End Sub
Sub GetToolWindow(ByVal dte As DTE2)
Dim win As OutputWindow
win = _applicationObject.ToolWindows.OutputWindow
Dim aStr As String = win.Parent.Caption
win = CType(_applicationObject.ToolWindows.GetToolWindow(aStr), _
OutputWindow)
MsgBox("The window caption, obtained via GetToolWindow method, _
is: " & vbCr & win.Parent.Caption)
End Sub
using EnvDTE;
using EnvDTE80;
using System.Windows.Forms;
public void OnConnection(object application,
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
GetToolWindow (_applicationObject);
}
public void GetToolWindow (DTE2 dte)
{
Output win;
win = _applicationObject.ToolWindows.OutputWindow;
String aStr = win.Parent.Caption;
win =
(OutputWindow)_applicationObject.ToolWindows.GetToolWindow(aStr);
MessageBox.Show(("The window caption, obtained via GetToolWindow
method, is: " + "\n" + win.Parent.Caption);
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.