We help IT Professionals succeed at work.

ComboBox with strings and icons

VapiSoft used Ask the Experts™

I need to create a ComboBox with icons and stings in Windows.
I can add strings if the style is not OwnerDraw,  or icons if I set it to ownerdraw and add the icons using SetItemData.
But I cannot add both.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®


It is called XP (or office) style.
It is a flat combobox with out the gray button only a small triangle (just like in the IE address-bar).
I'm not sure I follow you :)

that sample shows how to create inherited control to show icons and text in the combobox, so how is it different from what you asked?


You can see here an example of what I want.
It is in VB and I need it in C.

Also, look in the attached picture for a combobox in IE (I need something like that).
Top Expert 2016
it is not clear why you cannot add both string and icon when using an owner-draw combobox.

when setting the owner-draw style of a combobox you must provide a DrawItem callback function with you CComboBox derived class which gets a device context and a rectangle for each line. here you can draw any image or text or whatever.

ok, I guess you can get XP styles by using a manifest (see e.g. http://www.codeproject.com/KB/cpp/xpstylemfc.aspx).

If you're doing C++ in .net environment, you could simply use vb.net version (perhaps with few changes here and there for manifest)


To Sara - The poblem is that the top part (the edit and the open-button) look like old combo.

to alexey - I worked for exe, but I cannot make it work in the DLL.
Do you have a suggestion?
hmm, does your dll have the same manifest? because it shouldn't have any difference, maybe check your exe's manifest when you use 'flat combo' from the dll


OK, It was different so I changed it to use the same manifest file.
It didn't help.
I am trying it with MSVS6 but I tried it also in Visula Studio 2010 Express (I added a #program line that adds the mainfest to the linker), but they both fail to work.

I windering if there is a simpler way to do it?


I want to close it, and thanks for the help.
i don't remember how but I solved it.