Export (0) Print
Expand All

Document.ActiveWindow Property

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

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Window ActiveWindow { get; }

Property Value

Type: EnvDTE.Window
A Window object.

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."

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);
   }
}

Show:
© 2014 Microsoft