I am designing a lot of TCheckBox at runtime, and uses mathematical formulas for placing these in columns and rows afterwards on a form.
I assign an on click event that is exactly the same on all of them, and everything work,
except... Color.
My OnClick event is made like this:
procedure TForm1.CheckBoxClicked(sender: TObject) ;
begin
if Sender is TCheckBox then
begin
WITH TCheckBox(Sender) DO BEGIN
IF Color=clBtnFace THEN BEGIN
Caption:='TESTER 1';
TCheckBox(Sender). Color:=clGreen;
TCheckBox(Sender).Font.Color:=clGreen;
Checked:=TRUE;
END
ELSE IF Color=clGreen THEN BEGIN
Caption:='TESTER 2';
Color:=clRed;
Font.Color:=Color;
Checked:=TRUE;
END
ELSE IF Color=clRed THEN BEGIN
Caption:='TESTER 3';
Color:=clBtnFace;
Font.Color:=Color;
Checked:=FALSE;
END ELSE Color:=clBtnFace;
Repaint;
Update;
END;
end;
end;
My aim is to change the color one way or another on either the background or the actual text/font, but I have so far been unable to change this.
I get checkboxes that I can click on. Each click does cycle through the different captions. The color property is set correctly, otherwise this cycling would not work.
My form however when I run the program...
Always a green check when it is checked. Always Black text.
I have tried making all Parent properties False, but still I only get Black text and no color.
I would really appreciate some explanation and a solution to this problem.
I use Delphi 9 and Delphi 5, and experience the same on two different computers.
On Delphi 9, I cant even change Font color when I place CheckBoxes on the form.
On Delphi 5, I can change Font Color on CheckBoxes on the form, but when program run, then I only get Black Text.
Delphi 9 is installed on Windows XP. Delphi 5 is installed on Windows 7.
Thanks in advance.
Morten.