mfc

MFC CDateTimeCtrl::SetMonthCalColor doesn't work


in header file:

class CTyDate : public CDateTimeCtrl

in cpp file:

void CTyDate::PreSubclassWindow()
{
    CDateTimeCtrl::PreSubclassWindow();
    int n1 = 0;
    n1 = SetMonthCalColor(MCSC_TITLEBK, RGB(255, 0, 0));
    n1 = SetMonthCalColor(MCSC_MONTHBK, RGB(255, 0, 0));
    n1 = SetMonthCalColor(MCSC_TEXT, RGB(255, 0, 0));
    n1 = SetMonthCalColor(MCSC_TITLETEXT, RGB(255, 0, 0));
    n1 = SetMonthCalColor(MCSC_BACKGROUND, RGB(255, 0, 0));
    n1 = SetMonthCalColor(MCSC_TRAILINGTEXT, RGB(255, 0, 0));
}


I make a new class to owner draw this CDateTimeCtrl. I make sure this new class was bind correct and the function CTyDate::PreSubclassWindow() already run into.But nothing happened,the view of DateTimeCtrl was same as before.


Solution

  • I gave up to use this function, it does not work any more in Windows 10. I implement my custom draw by WM_PAINT. Although I need to wrote more code, but finally it work well;

    enter image description here