[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Controls' (#lcl)

TWinControl.CanSetFocus

Is this control allowed to receive the focus?

Declaration

Source position: controls.pp line 2237

public function TWinControl.CanSetFocus: Boolean; virtual;

Description

Checks if the control can get focus, i.e. if all its parents are visible and enabled.

A possible usage:

if MyControl.CanSetFocus then
  MyControl.SetFocus;
          

CanSetFocus should be prefered over CanFocus if used in CanSetFocus/SetFocus combination because it checks also if the parent form can receive focus and thus prevents the "cannot focus an invisible window" LCL exception.

See also

TWinControl.CanFocus

  

Is this control allowed to receive the focus when parent form is visible?

The latest version of this document can be found at lazarus-ccr.sourceforge.net.