共用方式為


WindowVisibilityEvents Interface

Definition

Tells whether ToolWindows are visible (hide or show). Use this object for functionality and refer to WindowVisibilityEventsClass for this object's documentation.

public interface class WindowVisibilityEvents : EnvDTE80::_dispWindowVisibilityEvents_Event, EnvDTE80::_WindowVisibilityEvents
public interface class WindowVisibilityEvents : EnvDTE80::_dispWindowVisibilityEvents_Event, EnvDTE80::_WindowVisibilityEvents
__interface WindowVisibilityEvents : EnvDTE80::_dispWindowVisibilityEvents_Event, EnvDTE80::_WindowVisibilityEvents
[System.Runtime.InteropServices.CoClass(typeof(EnvDTE80.WindowVisibilityEventsClass))]
[System.Runtime.InteropServices.Guid("84DE07BC-43A2-4275-BCF9-D207D20E49ED")]
public interface WindowVisibilityEvents : EnvDTE80._dispWindowVisibilityEvents_Event, EnvDTE80._WindowVisibilityEvents
[System.Runtime.InteropServices.CoClass(typeof(EnvDTE80.WindowVisibilityEventsClass))]
[System.Runtime.InteropServices.Guid("84DE07BC-43A2-4275-BCF9-D207D20E49ED")]
[System.Runtime.InteropServices.ComVisible(false)]
public interface WindowVisibilityEvents : EnvDTE80._dispWindowVisibilityEvents_Event, EnvDTE80._WindowVisibilityEvents
[<System.Runtime.InteropServices.CoClass(typeof(EnvDTE80.WindowVisibilityEventsClass))>]
[<System.Runtime.InteropServices.Guid("84DE07BC-43A2-4275-BCF9-D207D20E49ED")>]
type WindowVisibilityEvents = interface
    interface _WindowVisibilityEvents
    interface _dispWindowVisibilityEvents_Event
[<System.Runtime.InteropServices.CoClass(typeof(EnvDTE80.WindowVisibilityEventsClass))>]
[<System.Runtime.InteropServices.Guid("84DE07BC-43A2-4275-BCF9-D207D20E49ED")>]
[<System.Runtime.InteropServices.ComVisible(false)>]
type WindowVisibilityEvents = interface
    interface _WindowVisibilityEvents
    interface _dispWindowVisibilityEvents_Event
Public Interface WindowVisibilityEvents
Implements _dispWindowVisibilityEvents_Event, _WindowVisibilityEvents
Derived
Attributes
Implements

Examples

Run this example and open and close the Command Window and the Output Window in the Visual Studio IDE to see event capturing methods in action.

Imports System  
Imports Microsoft.VisualStudio.CommandBars  
Imports Extensibility  
Imports EnvDTE  
Imports EnvDTE80  

Public Class Connect  
    Implements IDTExtensibility2  
    Dim applicationObject As DTE2  
    Dim addInInstance As AddIn  
    Public WithEvents windowsVisEvents As EnvDTE80.WindowVisibilityEvents  
    Public Sub New()  
    End Sub  
    Public Sub OnConnection(ByVal application As Object, _  
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _  
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection  
    applicationObject = CType(application, DTE2)  
    addInInstance = CType(addInInst, AddIn)  
    Dim toolwin As EnvDTE80.ToolWindows  
    toolwin = applicationObject.ToolWindows  
    windowsVisEvents = CType(toolwin.DTE.Events, _  
    Events2).WindowVisibilityEvents  
End Sub  
Private Sub windowsVisEvents_WindowHiding(ByVal Window As _  
 EnvDTE.Window) Handles windowsVisEvents.WindowHiding  
    MsgBox(Window.Caption & " is hiding.")  
End Sub  
Private Sub windowsVisEvents_WindowShowing(ByVal Window As _  
 EnvDTE.Window) Handles windowsVisEvents.WindowShowing  
    MsgBox(Window.Caption & " is showing.")  
End Sub  
Public Sub OnDisconnection(ByVal disconnectMode _  
 As ext_DisconnectMode, ByRef custom As Array) Implements  _  
IDTExtensibility2.OnDisconnection  
    windowsVisEvents = Nothing  
End Sub  
Public Sub OnAddInsUpdate(ByRef custom As Array) Implements _  
 IDTExtensibility2.OnAddInsUpdate  
End Sub  
Public Sub OnStartupComplete(ByRef custom As Array) Implements _  
 IDTExtensibility2.OnStartupComplete  
End Sub  
Public Sub OnBeginShutdown(ByRef custom As Array) Implements _  
 IDTExtensibility2.OnBeginShutdown  
End Sub  
End Class  
namespace CS_Events_Code  
{  
using System;  
using Microsoft.VisualStudio.CommandBars;  
using Extensibility;  
using EnvDTE;  
using EnvDTE80;  
using System.Windows.Forms;  
  public class Connect : Object, IDTExtensibility2  
  {  
   public Connect()  
   {  
   }  
   public void OnConnection(object application, ext_ConnectMode  
 connectMode, object addInInst, ref Array custom)  
    {  
    applicationObject = (DTE2)application;  
    addInInstance = (AddIn)addInInst;  
    EnvDTE80.Events2 events = (EnvDTE80.Events2  
 )applicationObject.Events;  
    windowsVisEvents =   
(EnvDTE80.WindowVisibilityEvents)events.get_WindowVisibilityEvents  
(null);  
    // Connect to each delegate exposed from the windows visibiliy   
    // events object retrieved above  
    windowsVisEvents.WindowHiding +=new   
_dispWindowVisibilityEvents_WindowHidingEventHandler  
(this.WindowHiding);   
    windowsVisEvents.WindowShowing +=new   
_dispWindowVisibilityEvents_WindowShowingEventHandler  
(this.WindowShowing);  
   }  
   public void OnDisconnection(ext_DisconnectMode disconnectMode,  
 ref Array custom)  
   {  
    if (windowsVisEvents != null)  
    {  
        windowsVisEvents.WindowHiding -= new   
_dispWindowVisibilityEvents_WindowHidingEventHandler  
(this.WindowHiding);  
       windowsVisEvents.WindowShowing -= new   
_dispWindowVisibilityEvents_WindowShowingEventHandler  
(this.WindowShowing);  
   }  
   }  
   public void OnAddInsUpdate(ref Array custom)  
   {  
   }  
public void OnStartupComplete(ref Array custom)  
   {  
   }  
public void OnBeginShutdown(ref Array custom)  
   {  
   }  
private DTE2 applicationObject;  
private AddIn addInInstance;  
private EnvDTE80.WindowVisibilityEvents windowsVisEvents;  
public void WindowHiding(EnvDTE.Window winRef)  
   {  
    MessageBox.Show("The window " + winRef.Caption + " is hiding.");  
   }  
public void WindowShowing(EnvDTE.Window winRef)  
   {  
    MessageBox.Show("The window " + winRef.Caption + " is showing.");  
   }  
  }  
}  

Methods

add_WindowHiding(_dispWindowVisibilityEvents_WindowHidingEventHandler) (Inherited from _dispWindowVisibilityEvents_Event)
add_WindowShowing(_dispWindowVisibilityEvents_WindowShowingEventHandler) (Inherited from _dispWindowVisibilityEvents_Event)
remove_WindowHiding(_dispWindowVisibilityEvents_WindowHidingEventHandler) (Inherited from _dispWindowVisibilityEvents_Event)
remove_WindowShowing(_dispWindowVisibilityEvents_WindowShowingEventHandler) (Inherited from _dispWindowVisibilityEvents_Event)

Events

WindowHiding

This API supports the product infrastructure and is not intended to be used directly from your code.

Microsoft Internal Use Only.

(Inherited from _dispWindowVisibilityEvents_Event)
WindowShowing

This API supports the product infrastructure and is not intended to be used directly from your code.

Microsoft Internal Use Only.

(Inherited from _dispWindowVisibilityEvents_Event)

Applies to