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

# TWinControl.RemoveFocus

Notifies the parent Form when the control cannot be focused.

## Declaration

Source position: controls.pp line 2306

`protected procedure TWinControl.RemoveFocus(`
`Removing: Boolean`
`);`

## Arguments

`Removing` |  | True if the control is being freed, False when it is not enabled or not visible.

## Description

RemoveFocus is a method used to notify the parent form when the control cannot be focused. RemoveFocus is called from methods like Destroy and RemoveControl, where the control will no longer exist on the parent form. It is also called from methods like CMEnabledChanged and CMVisibleChanged, where the parent form should no longer allow the control to be focused.

RemoveFocus calls GetParentForm to get the parent form instance, and calls its DefocusControl method to ensure that the control is removed as the ActiveControl (when assigned).

## See also

TWinControl.CMEnabledChanged |  | Handler signalled when the Enabled property has been changed.
TWinControl.CMVisibleChanged |  | Handles Focus changes, and forces UpdateControlState.
TWinControl.RemoveControl |  | Removes the specified control from the Controls property.
TWinControl.Destroy |  | Destructor for the class instance.
TCustomForm.DefocusControl |  | Updates ActiveControl if it is to be de-focused.
TCustomForm.ActiveControl |  | Gets or sets the active control on the form.
GetParentForm |  | Gets the form instance for the specified Control.