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

TWinControl.CanFocus

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

Declaration

Source position: controls.pp line 2177

public function TWinControl.CanFocus: Boolean; virtual;

Description

Checks if the control can get focus when parent form is visible, i.e. if all its parents except the form are visible and enabled.

A possible usage:

if FormFoo.EditFoo.CanFocus then
  FormFoo.ActiveControl := FormFoo.EditFoo;
          

Please note that this function returns True also if the parent form isn't visible and therefore a consecutive SetFocus call could throw an exception. Use CanSetFocus in this case.

See also

TWinControl.CanSetFocus

  

Is this control allowed to receive the focus?