Share via


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

その他の技術情報

方法 : オートメーション オブジェクト モデルのコード例をコンパイルおよび実行する