I have a CComboBox in a dialog.
I want to set differentt colors for certain itemtext (or make them bold).
First of all, is there a direct way ?
What I did is I derived a CXComboBox
: CComboBox with owner draw fixed flag
set. then DrawItem of new class is:
void CXComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
ASSERT(lpDrawItemStruct->CtlType == ODT_COMBOBOX);
CString strItem((LPCTSTR) lpDrawItemStruct->itemData);
COLORREF crOldTextColor = dc.GetTextColor();
if(lpDrawItemStruct->itemID == 2)
crOldTextColor = dc.SetTextColor(RGB(255,0,0));
dc.DrawText(strItem, &lpDrawItemStruct->rcItem, 0);
this seem working, but the problem comes
when I use
member, it does not give the text correctly ? is there something I am missing ?