Share via


ToolWindows 接口

通过在 shell 工具窗口的本机类型中提供对 shell 工具窗口的方便访问,来改进对象模型中的工具窗口的发现能力和可用性。

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

语法

声明
<GuidAttribute("19AC6F68-3019-4D65-8D98-404DFB96B8E2")> _
Public Interface ToolWindows
[GuidAttribute("19AC6F68-3019-4D65-8D98-404DFB96B8E2")]
public interface ToolWindows
[GuidAttribute(L"19AC6F68-3019-4D65-8D98-404DFB96B8E2")]
public interface class ToolWindows
[<GuidAttribute("19AC6F68-3019-4D65-8D98-404DFB96B8E2")>]
type ToolWindows =  interface end
public interface ToolWindows

ToolWindows 类型公开以下成员。

属性

  名称 说明
公共属性 CommandWindow 获取 CommandWindow 对象。
公共属性 DTE 获取顶级扩展性对象。
公共属性 ErrorList 获取 IDE 中显示的错误的列表。
公共属性 OutputWindow 获取 OutputWindow 对象。
公共属性 SolutionExplorer 获取一个表示“解决方案资源管理器”UIHierarchy 对象。
公共属性 TaskList 获取 TaskList 对象。
公共属性 ToolBox 获取 ToolBox 对象。

页首

方法

  名称 说明
公共方法 GetToolWindow 使用户可以按窗口标题检索窗口。

页首

备注

可通过成员属性访问 Visual Studio 工具窗口。 可以使用 GetToolWindow 函数来查找其他工具窗口。

示例

此示例添加一个标题为“My output”的**“输出窗口”**,激活它,并显示通过父 ToolWindows 对象的 Collection 对象访问到的所有工具窗口。 有关如何作为外接程序运行此示例的更多信息,请参见 如何:编译和运行自动化对象模型代码示例

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)
    OutputToolWindow(_applicationObject)
End Sub
Public Sub OutputToolWindow(ByVal dte As DTE2)
    Dim myOut As OutputWindow
    myOut = _applicationObject.ToolWindows.OutputWindow
    Dim myPane As OutputWindowPane
    Dim txt As String
    txt = ""
    MsgBox("Creating an output window.")
    myPane = myOut.OutputWindowPanes.Add("My output")
    myPane.Activate()
    MsgBox("Adding some text to the output window...")
    myPane.OutputString("This is the collection of tool windows, _
 reached through the Output Window object:" & vbCr)
    For Each tempWindow As EnvDTE80.Window2 In myOut.Parent.Collection
        txt = txt & (tempWindow.Caption & vbCr)
    Next tempWindow
    MsgBox("Displaying all the tool window captions _
 in the Output window...")
    myPane.OutputString(txt)
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;
    OutputToolWindow(_applicationObject);
}
public void OutputToolWindow(DTE2 dte)
{
    OutputWindow myOut;
    myOut = _applicationObject.ToolWindows.OutputWindow;
    OutputWindowPane myPane;
    String txt = null;
    MessageBox.Show("Creating an output window.");
    myPane = myOut.OutputWindowPanes.Add("My output");
    myPane.Activate();
    MessageBox.Show("Adding some text to the output window...");
    myPane.OutputString("This is the collection of tool
 windows,reached through the Output Window object:" + "\n");
    foreach (EnvDTE80.Window2 tempWindow in myOut.Parent.Collection)
    {
        txt = txt + (tempWindow.Caption + "\n");
    }
    MessageBox.Show("Displaying all the tool window captions 
in the output window...");
    myPane.OutputString(txt);
}

请参阅

参考

EnvDTE80 命名空间