DTE2.ActiveWindow Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the currently active window, or the top-most window if no others are active.
public:
property EnvDTE::Window ^ ActiveWindow { EnvDTE::Window ^ get(); };
public:
property EnvDTE::Window ^ ActiveWindow { EnvDTE::Window ^ get(); };
[System.Runtime.InteropServices.DispId(205)]
public EnvDTE.Window ActiveWindow { [System.Runtime.InteropServices.DispId(205)] get; }
[<System.Runtime.InteropServices.DispId(205)>]
[<get: System.Runtime.InteropServices.DispId(205)>]
member this.ActiveWindow : EnvDTE.Window
Public ReadOnly Property ActiveWindow As Window
Property Value
A Window object. Returns Nothing
if no windows are open.
Implements
- Attributes
Examples
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);
}
Remarks
ActiveWindow returns the environment's active window.
You can set the caption only on Tool windows. If you attempt to set the caption on other window types, such as Document windows, you get the error, "Unspecified error."