Включить или выключить флажок у другого приложения
{
The function CheckCheckBox() checks or unchecks a Checkbox in another
window.
Parameter:
hApp : Handle to the parent window of the Checkbox.
ClassName: Class name of the Checkbox.
(For Delphi-Applications: TCheckBox. For C, VB,..: Checkbox)
bValue: Determines whether the check box is in the checked state.
CheckBoxNr: Number of the CheckBox (useful if there are several Checkboxes)
}
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;
|
|