DTE2.ActiveWindow 属性

获取当前活动窗口,如果没有其他活动窗口,则返回最顶层的窗口。

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

语法

声明
ReadOnly Property ActiveWindow As Window
Window ActiveWindow { get; }
property Window^ ActiveWindow {
    Window^ get ();
}
abstract ActiveWindow : Window with get
function get ActiveWindow () : Window

属性值

类型:Window
一个 Window 对象。如果没有打开窗口,则返回 Nothing。

备注

ActiveWindow 返回环境的活动窗口。

只可对“工具”窗口设置标题。 如果尝试对其他窗口类型(如“文档”窗口)设置标题,则会遇到错误“未指定的错误”。

示例

Sub ActiveWindowExample(ByVal dte As DTE2)

    ' Create two text files.
    Dim doc1 As Document = _
        dte.ItemOperations.NewFile(, "Document1").Document
    dte.ItemOperations.NewFile(, "Document2")

    MsgBox("The active window is " & dte.ActiveWindow.Caption)

    If MsgBox("Activate Document1?", MsgBoxStyle.YesNo) = _
        MsgBoxResult.Yes Then
        doc1.Activate()
    End If

    MsgBox("The active window is " & dte.ActiveWindow.Caption)

End Sub
public void ActiveWindowExample(DTE2 dte)
{
    // Create two text files.
    Document doc1 = dte.ItemOperations.NewFile(@"General\Text File", 
        "Document1", Constants.vsViewKindPrimary).Document;
    dte.ItemOperations.NewFile(@"General\Text File", "Document2", 
        Constants.vsViewKindPrimary);

    MessageBox.Show("The active window is " + 
        dte.ActiveWindow.Caption);

    if (MessageBox.Show("Activate Document1?", "", 
        MessageBoxButtons.YesNo) == DialogResult.Yes)
        doc1.Activate();

    MessageBox.Show("The active window is " + 
        dte.ActiveWindow.Caption);
}

.NET Framework 安全性

请参阅

参考

DTE2 接口

EnvDTE80 命名空间

其他资源

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