[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 2408

public function TWinControl.CanSetFocus: Boolean; virtual;

Description

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

A possible usage:

if MyControl.CanSetFocus then
   MyControl.SetFocus;

CanSetFocus should be preferred 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?

TWinControl.SetFocus

  

Ensures that the control or window handle has focus.


Version 3.2 Generated 2024-02-25 Home