Share via


Document.ActiveWindow Property

Definition

Gets the currently active window, or the topmost window if no others are active. Returns Nothing if no windows are open.

public:
 property EnvDTE::Window ^ ActiveWindow { EnvDTE::Window ^ get(); };
public:
 property EnvDTE::Window ^ ActiveWindow { EnvDTE::Window ^ get(); };
[System.Runtime.InteropServices.DispId(102)]
public EnvDTE.Window ActiveWindow { [System.Runtime.InteropServices.DispId(102)] get; }
[<System.Runtime.InteropServices.DispId(102)>]
[<get: System.Runtime.InteropServices.DispId(102)>]
member this.ActiveWindow : EnvDTE.Window
Public ReadOnly Property ActiveWindow As Window

Property Value

A Window object.

Attributes

Examples

public void WindowExample(DTE2 dte)  
{  // Before running, create a text file named   
   // "TextFile1.txt", include it in your solution,  
   // and select some text.  
   Window win;  
   Document doc;  
   if (dte.Documents.Count > 0)  
   {  
      doc = dte.Documents.Item("TextFile1.txt");  
      win = doc.ActiveWindow;  
      // Show the name of the project that contains this window and document.  
      MessageBox.Show(win.Project.Name);  
   }  
}  

Remarks

ActiveWindow returns the document'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."

Applies to