whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

39 Visitors Online


 
...check or uncheck a Checkbox in another window?
Autor: Thomas Stutz
[ Print tip ]  

Tip Rating (8):  
     


{
  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)
}

{
  Die Funktion CheckCheckBox() markiert (Checked:= True) eine Checkbox in einem
  fremden Fenster.

  Parameter:
  hApp : Handle des Fensters, auf welchem die Checkbox liegt.
  ClassName: Klassenname der Checkbox.
  (Bei Delphi-Anwendungen TCheckBox, bei C, VB,..: Checkbox)
  bValue: Wenn True, dann wird die Checkbox markiert.
  CheckBoxNr: Nummer der CheckBox (nützlich, wenn mehrere Checkboxen vorhanden sind)
  ("Reihenfolge der Nummern wird durch FindWindowEx bestimmt")
}

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;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners