TCustomForm.ActiveControl property
Gets or sets the active control on the form.
Declaration
property ActiveControl: TWinControl read FActiveControl write SetActiveControl;Description
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.
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
