Compartilhar via


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

  1. Monitor selection events by obtaining an IVsMonitorSelection object from SVsShellMonitorSelection.

  2. Call AdviseSelectionEvents and provide it your IVsSelectionEvents object.

  3. In your call to OnElementValueChanged, look for elementid==SEID_WindowFrame.

  4. Test the varValueNew parameter for two things:

    1. The window frame you are looking for.

    2. The point at which your program loses the selection to that window frame.