How to change the TCheckBox state without assigning an OnClick event handler (Views: 27)
Problem/Question/Abstract: I was wondering if there was any way to change the state of the TCheckBox control without setting off the OnClick Event Handler. If certain other properties are incorrect, I want void the state the event was set to by the Click, without setting of the event handler again. Answer: procedure TForm1.Button1Click(Sender: TObject); begin if Button1.Tag = 0 then begin SendMessage(CheckBox1.handle, BM_SETCHECK, BST_CHECKED, 0); Button1.Tag := 1; end else begin SendMessage(CheckBox1.handle, BM_SETCHECK, BST_UNCHECKED, 0); Button1.Tag := 0; end; end; procedure TForm1.CheckBox1Click(Sender: TObject); begin Showmessage('clicked'); end; |