1

The MFC combobox is really a wierd design.

I use "drop list" type combo box.

HBRUSH CValueInputDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)  
{
    HBRUSH hBrush = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
    if (nCtlColor == CTLCOLOR_STATIC || nCtlColor == CTLCOLOR_EDIT)
    {
        pDC->SetTextColor(RGB(255, 255, 255));  
        pDC->SetBkMode(TRANSPARENT);  
        hBrush = (HBRUSH)GetStockObject(NULL_BRUSH);
    }    
    return hBrush;
}

what I do is having all my CStatic and CEdit color WHITE.

but i discover that I also change the combobox's edit to white.

that is what I don't want.

that is what I don't want. and I can't stop it from

pWnd->GetDlgCtrlID() == IDC_COMBO

it is so unfriendly. this combo box.

4

1 回答 1

4

The Edit box is a child of the combo box. Try this:

pWnd->GetParent()->GetDlgCtrlID() == IDC_COMBO

于 2012-08-09T14:57:08.797 回答