ToolWindows 介面

藉由提供原生型別中 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 函式找到。

範例

這個範例會新增名為「我的輸出」的 [輸出視窗] 並加以啟動,然後顯示所有透過 ToolWindows 父物件之 Collection 物件抵達的工具視窗。 如需如何像執行增益集一般,執行這個範例的詳細資訊,請參閱 HOW TO:編譯和執行 Automation 物件模型程式碼範例

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 命名空間