![]() |
||||
|
Introduction The IDE can be in one of these modes:
More Information When you want to know programatically the mode of the IDE, you could think that you can use the EnvDTE.DTE.Mode property. However, the EnvDTE.vsIDEMode enum returned by that property has only two states (vsIDEModeDebug, vsIDEModeDesign), not three. Fortunately, you can use the EnvDTE.DebuggerEvents class, that provides the OnEnterDesignMode, OnEnterBreakMode and OnEnterRunMode events to track the current mode, assuming that the IDE is initially at design-time. So, you can use this code: Public Class Connect Implements IDTExtensibility2 Private Enum IDEMode
Design = 1
Debug = 2
Run = 3
End Enum
Private _applicationObject As DTE2 Private _IDEMode As IDEMode Private WithEvents _debuggerEvents As DebuggerEvents 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)
_IDEMode = IDEMode.Design
_debuggerEvents = _applicationObject.Events.DebuggerEvents
End Sub
Private Sub _debuggerEvents_OnEnterBreakMode(ByVal Reason As EnvDTE.dbgEventReason, _
ByRef ExecutionAction As EnvDTE.dbgExecutionAction) Handles _debuggerEvents.OnEnterBreakMode
_IDEMode = IDEMode.Debug
End Sub
Private Sub _debuggerEvents_OnEnterDesignMode(ByVal Reason As EnvDTE.dbgEventReason) _
Handles _debuggerEvents.OnEnterDesignMode
_IDEMode = IDEMode.Design
End Sub
Private Sub _debuggerEvents_OnEnterRunMode(ByVal Reason As EnvDTE.dbgEventReason) _
Handles _debuggerEvents.OnEnterRunMode
_IDEMode = IDEMode.Run
End Sub
...
End Class Go back to the 'Resources for Visual Studio .NET extensibility' section for more articles like this
You can code, design, locate code and document your apps much faster using VB.NET, C#, C++ or Visual J#:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||