Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

enter image description here

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
230 views
Welcome To Ask or Share your Answers For Others

1 Answer

I just check the state for ODS_COMBOBOXEDIT. If ifthe dcumentation says that this flag is set for the edit Control, it works for the drop down list to.

I have checked combo box implementation like you that works in the sane way.

bool bDrawStaticControl = (pDIS->itemState & ODS_COMBOBOXEDIT)!=0;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...