How to: Fire Events When the Editor Loses Focus
Note
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
Sometimes it is necessary to know when an editor loses focus on the window frame. For example, you might need to extract code from a code window after the editor is no longer focused on it. The following procedure provides the steps to follow to receive notification of the editor losing focus.
To fire an event in response to an editor losing focus
Monitor selection events by obtaining an IVsMonitorSelection object from SVsShellMonitorSelection.
Call AdviseSelectionEvents and provide it your IVsSelectionEvents object.
In your call to OnElementValueChanged, look for
elementid==SEID_WindowFrame
.Test the
varValueNew
parameter for two things:The window frame you are looking for.
The point at which your program loses the selection to that window frame.