获取当前活动窗口,如果没有其他活动窗口,则返回最顶层的窗口。
命名空间:  EnvDTE80
程序集:  EnvDTE80(在 EnvDTE80.dll 中)
语法
声明
ReadOnly Property ActiveWindow As Window
    Get
Window ActiveWindow { get; }
property Window^ ActiveWindow {
    Window^ get ();
}
abstract ActiveWindow : Window
function get ActiveWindow () : Window
属性值
类型:EnvDTE.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 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。