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

# TWinControl.SetFocus

Ensures that the control or window handle has focus.

## Declaration

Source position: controls.pp line 2423

`public procedure TWinControl.SetFocus; virtual;`

## Description

SetFocus is a procedure used to give focus to the current control. SetFocus calls GetParentForm for the control instance, and uses its FocusControl method to change the focused control.

If the parent Form is unassigned (contains Nil), the LCL interface is used to change focus to the handle for the control. No actions are performed in the method when Form is unassigned and the control does not have an allocated handle.