ToolWindows.GetToolWindow 方法

使用户可以按窗口标题检索窗口。

命名空间:  EnvDTE80
程序集:  EnvDTE80(在 EnvDTE80.dll 中)

语法

声明
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

参数

返回值

类型:System.Object
Window 对象。

示例

此外接程序在使用 GetToolWindow 方法检索输出窗口之后,获取输出窗口的标题。有关如何运行自动化示例的更多信息,请参见 如何:编译和运行自动化对象模型代码示例

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 安全性

请参见

参考

ToolWindows 接口

EnvDTE80 命名空间