Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3027

Change text and bkg color of CComboBox

$
0
0
I have a derived CComboBox class, where I tried to change text and background of edit from CComboBox, just like this:
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;
}

but is not working if CComboBox has CBS_DROPDOWNLIST style ... is working only for CBS_DROPDOWN style ... why ?
I attached a test app ...

Viewing all articles
Browse latest Browse all 3027

Latest Images

Trending Articles



Latest Images