Problem in changing the font color of a date time picker control.

I am using several date time picker controls in my project. One of the requirement is to change the font color of the combo box part of date time picker control. I have written the code for it in the OnCtlColor() method. But this is effective only when I select the content inside the combo part. Once the focus is shifted out of the combo part, font color changes back to the default system font color. Does anybody have solution?
[431 byte] By [SumitSharma] at [2007-12-25]
# 1

Actually

a combo box consists of an edit box and list box.

So you

have to set the color for both list box and edit box.

See the

sample snippet

if(

nCtlColor == CTLCOLOR_LISTBOX )


pDC->SetTextColor( RGB(0xFF,0,0));

if( nCtlColor == CTLCOLOR_EDIT)


pDC->SetTextColor( RGB(0xFF,0,0));

Sarath. at 2007-8-31 > top of Msdn Tech,Visual C++,Visual C++ General...
# 2

Thanks Sharath for your response!

Actually this message is generated for a DTP control only when I click inside the combo part of the control and the font color change persist only as long as the focus is on the combo part. I want the changed font color throughout the application life cycle. OnCtlColor works fine for other controls like edit box, combo box, list box, static control etc.

SumitSharma at 2007-8-31 > top of Msdn Tech,Visual C++,Visual C++ General...
# 3

I've tried implementing both CtlColor() and OnCtlColor() using Class Wizard and neither even get called in the debugger.

I have no problem with OnEraseBkgnd() and it seems to be painting the backgrounds just fine.

CTLCOLOR_EDIT and CTLCOLOR_LISTBOX probably do not apply to a Date and Time Picker since

1. There is no List Box, and

2. DTM_SETMCCOLOR is used to set the colors in the month drop down, the equivalent of a combo bo drop down.

and this is only useful in order to paint different colours for the edit control and the list box anyways.

However, like a combobox, perhaps it is possible to get access to the edit control itself somehow.

BobH2 at 2007-8-31 > top of Msdn Tech,Visual C++,Visual C++ General...