Forms Delphi

Title: How to check or uncheck a Checkbox in another window
procedure CheckCheckBox(hApp: HWND; ClassName: string; bValue: Boolean; CheckBoxNr: Integer);
var
i: Word;
hCheckBox: HWND;
begin
if not IsWindow(hApp) then Exit;
for i := 0 to CheckBoxNr do
hCheckBox := FindWindowEx(hApp, hCheckBox, PChar(ClassName), nil);
if IsWindow(hCheckBox) then
SendMessage(hCheckBox, BM_SETCHECK, Integer(bValue), 0);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
CheckCheckBox(Handle, 'TCheckBox', True, 1);
// Or / Oder
// CheckCheckBox(Handle, 'CheckBox', True, 1);
end;