DelphiDabbler Code Snippets Database

Snippet Selection

The following snippets from the Code Snippets Database have been requested.

ContainsFocus

Returns True if the specified control, or one of its child controls, currently has the input focus.

function ContainsFocus(Control: Controls.TWinControl): Boolean;
var
  FC: Controls.TWinControl;
begin
  FC := FocusedControl;
  if Assigned(FC) then
    Result := Control.ContainsControl(FocusedControl)
  else
    Result := False
end;

FocusedControl

Returns the name of the TWinControl that currently has the focus, or nil if there is no such control.

function FocusedControl: Controls.TWinControl;
begin
  Result := Controls.FindControl(Windows.GetFocus);
end;

View the whole database.

Go to the DelphiDabbler website.