SetFocus Event

Applies to:  CbtEvents object
See also:  Window object

Occurs when the keyboard focus is about to move from one window to another.

Syntax:

Public Event SetFocus(ByRef Window As Window, ByRef PreviousWindow As Window, ByRef Cancel As Boolean)

The CreateWindow event syntax has these parts:

Part Description
object The name of a CbtEvents object.  NB:  object must be declared using WithEvents.
Window The window about to receive focus.
PreviousWindow The window about to lose focus.
Cancel A boolean value that determines whether Window will receive the keyboard focus.  Setting Cancel to True will prevent Window from receiving the keyboard focus.

Remarks:

If the keyboard focus is within a Visual Basic application, then the SetFocus event will be triggered prior to the VB defined GotFocus event of the control gaining the focus.

Consequently, Screen.ActiveControl will contain a reference to the previously active control.

Example:

Control Highlighting

 

Home Copyright and Disclaimer