procedure CheckCheckBox(hApp: HWND; ClassName: string; bValue: Boolean);
var
i: Word;
hCheckBox: HWND;
begin
if not IsWindow(hApp) then Exit;
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
// CheckCheckBox(Handle, 'CheckBox', True, 1);
end;
if there are several CheckBoxes you will have to
hCheckBox := FindWindowEx(hApp, hCheckBox, PChar(ClassName), nil)
several times until you get the one you want
No comments:
Post a Comment