TForm.ActiveControl property
Declaration
property ActiveControl: ;Description
Not described here; this is what TCustomForm.ActiveControl says of it:
Gets or sets the active control on the form.
ActiveControl is a
TWinControl property which contains
the control which has focus on the form. The property can contain
Nil if
the parent form is hidden, disabled, or has never been activated.
Setting a new value for the property performs validity checks to ensure that
the specified control can receive focus when the form is Visible. An
EInvalidOperation exception is raised with the message in
SCannotFocus when the new property value contains:
- The current form instance.
- A control not parented by the current form instance.
- A control that returns False from its CanFocus method.
The value in the LastActiveControl property is updated with the existing value for ActiveControl if it is a control and not a TForm/TCustomForm instance. If the form (and not a control) was active, LastActiveControl is set to Nil.
At run-time, the new active control is focused and activated if its form is active (Active = True). ActiveChanged is called too. Both of these steps are omitted at design-time or when the component is loaded during component streaming.
The value in ActiveControl is updated in the FocusControl and
DefocusControl methods.
An experiment, built from Lazarus main 2dfa93c66e of 10-22-2026. Not the official Lazarus documentation.
