I have a derived CComboBox class, where I tried to change text and background of edit from CComboBox, just like this:
but is not working if CComboBox has CBS_DROPDOWNLIST style ... is working only for CBS_DROPDOWN style ... why ?Code:HBRUSH CMyComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here // if(CTLCOLOR_EDIT == nCtlColor || CTLCOLOR_MSGBOX == nCtlColor) { pDC->SetTextColor(RGB(255, 255, 0)); pDC->SetBkColor(RGB(255, 0, 0)); pDC->SetBkMode(TRANSPARENT); hbr = m_hBrush; } // TODO: Return a different brush if the default is not desired return hbr; }
I attached a test app ...




Reply With Quote
