Option Strict Off
Option Explicit Off
Imports EnvDTE
Imports System.Diagnostics

Public Module EnvironmentEvents

#Region "Automatically generated code, do not modify"
'Automatically generated code, do not modify
'Event Sources Begin
	<System.ContextStaticAttribute()> Public WithEvents DTEEvents As EnvDTE.DTEEvents
	<System.ContextStaticAttribute()> Public WithEvents DocumentEvents As EnvDTE.DocumentEvents
	<System.ContextStaticAttribute()> Public WithEvents WindowEvents As EnvDTE.WindowEvents
	<System.ContextStaticAttribute()> Public WithEvents TaskListEvents As EnvDTE.TaskListEvents
	<System.ContextStaticAttribute()> Public WithEvents FindEvents As EnvDTE.FindEvents
	<System.ContextStaticAttribute()> Public WithEvents OutputWindowEvents As EnvDTE.OutputWindowEvents
	<System.ContextStaticAttribute()> Public WithEvents SelectionEvents As EnvDTE.SelectionEvents
	<System.ContextStaticAttribute()> Public WithEvents SolutionEvents As EnvDTE.SolutionEvents
	<System.ContextStaticAttribute()> Public WithEvents SolutionItemsEvents As EnvDTE.ProjectItemsEvents
	<System.ContextStaticAttribute()> Public WithEvents MiscFilesEvents As EnvDTE.ProjectItemsEvents
	<System.ContextStaticAttribute()> Public WithEvents BuildEvents As EnvDTE.BuildEvents
	<System.ContextStaticAttribute()> Public WithEvents DebuggerEvents As EnvDTE.DebuggerEvents
'Event Sources End
'End of automatically generated code
#End Region

    ' This macro is disabled (the Handles part is commented out).

    Public Sub WindowEvents_WindowActivated(ByVal GotFocus As EnvDTE.Window, _
      ByVal LostFocus As EnvDTE.Window) ' Handles WindowEvents.WindowActivated

        ' Exit if the current window doesn't correspond to a document.
        If GotFocus.Document Is Nothing Then Exit Sub

        Dim Doc As Document
        Dim Win As EnvDTE.Window

        ' Scan through all the windows.
        For Each Win In DTE.Windows

            ' Ignore the window if it doesn't correspond to a document
            ' or is the currently active window.
            If Not Win.Document Is Nothing And Not Win Is GotFocus Then
                Win.Close()
            End If

        Next

    End Sub


End Module

