A TDateTime picker is a ComboBox where the drop-down list is replaced with a calendar.
I use XE2 VCL Styles and changing style does’nt affect TDateTimePicker Color & Font Color.
I have change the Calendar style with this question but the solution is not OK for the ComboBox, any idea ?
Now I plan to inherit a TComboBox for use with a TMonthCalendar but I would know if anybody had a better solution.
A TDateTime picker is a ComboBox where the drop-down list is replaced with a
Share
In order to use the workaround of the
CalColorsproperty, you must disable the Windows Theme in the drop down window of the TDateTimePicker component, for that you must use theDTM_GETMONTHCALmessage to get the window handle.Check this sample App
UPDATE 1
Change the background color of the “combobox” of the TDateTimePicker is a task limited by windows itself, because between others factors
SetBkColorfunction has not effect in this control because theWM_CTLCOLOREDITmessage is not handled by this control.So a possible solution is intercept the
WM_PAINTandWM_ERASEBKGNDmessages and wrote your own code to paint the control. When you uses the Vcl Styles you can use a Style hook to handle these messages.Check this code (only as a proof of concept)
Note: This style hook doesn’t draw the focused (selected) elements in the Inner text control (combobox) of the TDateTimePicker, i let this task for you.
UPDATE 2
I just wrote a vcl style hook which includes all the logic to apply the vcl style properly to the
TDateTimePickercomponent, without use the OnDropDown event or the OnCreate event of the form. You can find the vcl style hook here (as part of the vcl styles utils project)To use it you must add the Vcl.Styles.DateTimePickers unit to your project and register the hook in this way.