Windows2 接口

Windows 集合包含环境中的所有窗口。

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

语法

声明
<GuidAttribute("31EFB5B1-C655-4ADA-BB52-3ED87FB2A4AE")> _
Public Interface Windows2 _
    Inherits Windows
[GuidAttribute("31EFB5B1-C655-4ADA-BB52-3ED87FB2A4AE")]
public interface Windows2 : Windows
[GuidAttribute(L"31EFB5B1-C655-4ADA-BB52-3ED87FB2A4AE")]
public interface class Windows2 : Windows
[<GuidAttribute("31EFB5B1-C655-4ADA-BB52-3ED87FB2A4AE")>]
type Windows2 =  
    interface 
        interface Windows 
    end
public interface Windows2 extends Windows

Windows2 类型公开以下成员。

属性

  名称 说明
公共属性 Count 获取一个值,该值指示 Windows2 集合中对象的数目。
公共属性 DTE 获取顶级扩展性对象。
公共属性 Parent 获取 Windows2 集合的直接父对象。

页首

方法

  名称 说明
公共方法 CreateLinkedWindowFrame 创建一个 Window 对象,并在其中放置两个窗口。
公共方法 CreateToolWindow 创建一个新的包含指定 Document 对象或 ActiveX 控件的工具窗口。
公共方法 CreateToolWindow2 创建新工具窗口并在其中承载用户定义的 .NET 控件。
公共方法 GetEnumerator 获取集合中项的枚举。
公共方法 Item 返回 Windows 集合的一个索引成员。

页首

示例

此示例将**“输出窗口”“命令窗口”“解决方案资源管理器”**链接在一起。 然后,它操作这些链接窗口的宽度和高度,最后从链接窗口框架中取消停靠它们。

有关如何作为外接程序运行此示例的更多信息,请参见 如何:编译和运行自动化对象模型代码示例

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)
    LinkedWindowsExample(_applicationObject)
End Sub
Sub LinkedWindowsExample(ByVal dte As DTE2)
    Dim Frame As Window2
    Dim wins As Windows2
    wins = CType(_applicationObject.Windows, EnvDTE80.Windows2)
    Dim w1 As Window2 = _
 CType(_applicationObject.Windows.Item _
(Constants.vsWindowKindSolutionExplorer), EnvDTE80.Window2)
    Dim w2 As Window2 = _
 CType(_applicationObject.Windows.Item _
(Constants.vsWindowKindOutput), EnvDTE80.Window2)
    Dim w3 As Window2 = _
 CType(_applicationObject.Windows.Item _
(Constants.vsWindowKindCommandWindow), EnvDTE80.Window2)
    ' Create a linked window frame and dock Solution Explorer 
    ' and the Ouput window together inside it.
    Frame = CType(wins.CreateLinkedWindowFrame _
(w1, w2, vsLinkedWindowType.vsLinkedWindowTypeDocked), _
 EnvDTE80.Window2)
    MsgBox("Total number of windows in the linked window frame: " _
 & Frame.LinkedWindows.Count)
    ' Add another tool window, the Command window, to the frame with 
    ' the other two.
    Frame.LinkedWindows.Add(w3)
    MsgBox("Total number of windows in the linked window frame: " _
    & Frame.LinkedWindows.Count)
    ' Resize the entire linked window frame.
    Frame.Width = 500
    Frame.Height = 600
    MsgBox("Frame height and width changed. Now changing _
     Command window height.")
    ' Resize the height of the Command window.
    Frame.LinkedWindows.Item(3).Height = 800
    MsgBox("Now undocking the Command window from the frame.")
    ' Undock the Command window from the frame.
    Frame.LinkedWindows.Remove(w3)
    MsgBox("Now undocking the rest of the windows from the frame.")
    Frame.LinkedWindows.Remove(w2)
    Frame.LinkedWindows.Remove(w1)
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;
    LinkedWindowsExample(_applicationObject);
}
public void LinkedWindowsExample(DTE2 dte)
{
    Window2 Frame;
    Windows2 wins;
    wins = (EnvDTE80.Windows2)_applicationObject.Windows;
    Window2 w1 = 
(EnvDTE80.Window2)_applicationObject.Windows.Item
(Constants.vsWindowKindSolutionExplorer);
Window2 w2 =
 (EnvDTE80.Window2)_applicationObject.Windows.Item
(Constants.vsWindowKindOutput);
    Window2 w3 = 
(EnvDTE80.Window2)_applicationObject.Windows.Item
(Constants.vsWindowKindCommandWindow);
    // Create a linked window frame and dock Solution Explorer
    // and the Output window together inside it.
    Frame = (EnvDTE80.Window2)wins.CreateLinkedWindowFrame
(w1, w2, vsLinkedWindowType.vsLinkedWindowTypeDocked);
    MessageBox.Show("Total number of windows in the linked 
window frame: " + Frame.LinkedWindows.Count);
    // Add another tool window, the Command window, to the frame with
    // the other two.
    Frame.LinkedWindows.Add(w3);
    MessageBox.Show("Total number of windows in the linked 
window frame: " + Frame.LinkedWindows.Count);
    // Resize the entire linked window frame.
    Frame.Width = 500;
    Frame.Height = 600;
    MessageBox.Show("Frame height and width changed.
 Now changing Command window height.");
    // Resize the height of the Command window.
    Frame.LinkedWindows.Item(3).Height = 800;
    MessageBox.Show("Now undocking the Command window from 
the frame.");
    // Undock the Command window from the frame.
    Frame.LinkedWindows.Remove(w3);
    MessageBox.Show("Now undocking the rest of the windows 
from the frame.");
    Frame.LinkedWindows.Remove(w2);
    Frame.LinkedWindows.Remove(w1);
}

请参阅

参考

EnvDTE80 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例