Oh, but you can!
Just put this before your form declaration:
TCheckBox = class(StdCtrls.TCheckBox) public procedure CNCtlColorStatic(var Message: TWMCtlColorStatic); message CN_CTLCOLORSTATIC; end;
This re-declaration of TCheckBox is now used at runtime as a type streaming from your DFM form. Now do the following:
procedure TCheckBox.CNCtlColorStatic(var Message: TWMCtlColorStatic); begin SetTextColor(Message.ChildDC, ColorToRGB(clRed)); // or RGB(255,0,0)); SetBkMode(Message.ChildDC, TRANSPARENT); Message.Result := GetStockObject(NULL_BRUSH); end;
This intercepts the WM_CTLCOLORSTATIC message and changes the text color to red. This works in non-thematic mode for me (using WinXP classic), but not in thematic mode.
You must be aware that in order to allow the theme controls to send you this message, the control must provide the DTPB_USECTLCOLORSTATIC flag to Theme-drawing API. Unfortunately, this is not the default behavior, and I do not know how to do this. Take a look at this question.
PatrickvL
source share