1

I am using the CComboBoxEx control in MFC to select color for future drawing. Items in my ComboBox have small pictures – examples of color, and color names. Everything is Ok, except one annoying thing – when I select some item, not only text in selected item has different background, but the picture itself is changed. How to change only background color of text?

Example of selected item in picture

ComboBox lost focus - item displays normally

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
Andrey
  • 11
  • 1
  • Please show the code where you set the background color. – Werner Henze Aug 08 '18 at 12:22
  • It is not I who set the background color, it is normal behavior of ComboBox - when you select any item from the drop down list, and it is displayed in ComboBox as selected with background color (blue, as usual). Please, look at Environment / Fonts and Colors dialog window activated by Tools / Options in Microsoft Visual Studio. When you select any color in ComboBox, this item becomes selected, text background color becomes blue, but small picture with stays the same. – Andrey Aug 08 '18 at 12:37
  • As you can check with MS Spy++ Visual Studio has set `CBS_OWNERDRAWFIXED` for the control that you mention. So that might be the way to solve it, but that means you have to do all the drawing yourself. – Werner Henze Aug 09 '18 at 07:13

0 Answers0