title: Visual Studio extension: How do I find which tool window is in the foreground in a tab link group?
body: <p>In Visual Studio, you can group tool windows together and identify them by their tabs. For example, you might have the "Output", "Error List", and "Find Results 1" tool windows grouped together in a panel below your document. When you click on the "Output" tab, it comes to the foreground and grabs focus. If you click back to the document window, the "Output" tab is still on top (in the foreground).</p>
  
  <p>How can I programmatically (in a VS extension) determine (1) which windows are in the same tab group, and (2) which window is in the foreground, when given one of the windows in a group?</p>
  
  <p>Here's a code sample enumerating all windows:</p>
  
  <pre><code>    var dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));
      var windowOutput = dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
      foreach (EnvDTE.Window w in windowOutput.LinkedWindowFrame.Collection)
      {
          //gives every window, not just those grouped together
      }
  </code></pre>