How do i change the color of a TDateTimePicker
?
A Date and Time Picker can have a color:
Normally this is done by setting the Color:
procedure TForm1.FormCreate(Sender: TObject);
begin
DateTimePicker1.Color := clLime;
end;
But when using version 6 of the Date and Time Picker Control, the color no longer works:
I tried using SetWindowTheme
to disable the style of the TDateTimePicker
:
procedure TForm1.FormCreate(Sender: TObject);
begin
UxTheme.SetWindowTheme(DateTimePicker1.Handle, '', '');
DateTimePicker1.Color := clLime;
end;
But that just made it angry:
How do i change the color of a DateTimePicker?
I was going to settle for patching the VCL:
procedure TDateTimePicker.CreateWnd;
var
LChecked: Boolean;
begin
LChecked := FChecked;
inherited CreateWnd;
SetChecked(LChecked);
if Length(FFormat) > 0 then
DateTime_SetFormat(Handle, FFormat);
//20140911 Fix the .Color property not working
if Self.HandleAllocated then
Winapi.UxTheme.SetWindowTheme(Self.Handle, '', '');
end;
But disabling the theme of the window doesn't do it.
Bonus Chatter
You can change the color of a version 6 TComboBox
with Theme Styles still applied to it:
So it's not a fundamental limitation of common controls version 6 or visual styles.
Duplicate?
i think not.
- that question deals with how to make a DateTime picker honor the active Delphi style
- this question deals with hot to make a DateTime picker not honor the active Delphi style
And the answers in those questions do not let you change the color; which is what i need to do.
It's even more ridiculous to suggest that those answers apply, since Style Hooks only do anything if you are using a non-standard (Delphi) style.
WM_PAINT
andWM_ERASEBKGND
messages and wrote your own code to paint the control. – Pyorrhea