Search code examples
cwinapicombobox

Change the row (item) height of an owner-drawn drop list ComboBox?


I have an owner-drawn ComboBox (drop list) where, when the list is opened, I would like to draw for each item a text and below a 256x64 pixel bitmap.

The problem is that the height of the row for each item seems to be fixed so only my text appears.

Is it possible to modify the row height of an owner-drawn drop list ComboBox, please?

I could use a ListView control, but as this control is part of a toolbar, I don't have much space, so the drop list mode is perfect for me.

I don't know if that's possible, so I didn't try anything, I just draw my items with both the text and the bitmap, but only the text is shown.


Solution

  • To change the height of the items, you need to handle the WM_MEASUREITEM message in the WndProc of the ComboBox's parent window.

    Per the documentation:

    How to Create an Owner-Drawn Combo Box

    An owner-drawn combo box sends the WM_MEASUREITEM message to its parent window or dialog box procedure so that the application can set the dimensions of each list item. Because the example combo box has the CBS_OWNERDRAWFIXED style, the system sends the WM_MEASUREITEM message only once. Combo boxes with the CBS_OWNERDRAWVARIABLE style send a WM_MEASUREITEM message for each list item.