I have a custom drawn combobox with style CBS_DROPDOWNLIST
and CBS_OWNERDRAWVARIABLE
I can draw the items of the dropdownlist ok but whe user select an item it is drawn in the combobox static part [the part of combo that stay visible after selecting item and show the selection], I want to give it a custom text like in the following image
But I can't determine it I found a code like this
if(DrawItemStruct.CtlType == ODT_COMBOBOX)//the static part of the combo
DrawComboText(pDC, DrawItemStruct.itemID, &DrawItemStruct.rcItem);
else//the rest items
{
// Copy the text of the item to a string
char sItem[256];
GetString(sItem, DrawItemStruct.itemID);
biDrawText(pDC, sItem, -1, &DrawItemStruct.rcItem, f | DT_VCENTER | DT_SINGLELINE);
}
but when I used it I get all the items has CtlType == ODT_COMBOBOX
, when I debugged the above code It return ODT_COMBOBOX
for the static part, and for items of the drop down list it return ODT_LISTBOX
.
I want to know how to fix this problem, how to detect that I'm drawing the static part or a regular item in the dropdown list?
ODT_COMBOBOX
for text in static control.ODT_LISTBOX
for text from a Listbox item. That, or I didn't understand your question. – manuellDrawItemStruct.itemID == -1
– user1793036