2

I have a CComboBoxEx that displays some images and talk numbers:

Combo

How can the text of specific combo items properties?

  • Set font to bold.
  • Set font colour.

I know that for CComboBox I can make it owner draw and create the font and render the combo item myself. But this is CComboBoxEx and it is catering for images so owner draw would be harder.

Is there a simple solution to set specific CComboBoxEx items as bold and with a specific text colour? Thanks.

I saw this question and I thought I might be able to do it that way but I couldn't get it to work.

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
  • Your only chance is to make it owner-drawn. – Nick Nov 12 '19 at 16:07
  • How do I draw the icon and text? I know about drawing just the text strings alone, but with icons? – Andrew Truckle Nov 12 '19 at 16:08
  • CComboBoxEx has item icons, but not bold feature: https://learn.microsoft.com/en-us/cpp/mfc/reference/ccomboboxex-class?view=vs-2019 ... it is suitable for you ? – Flaviu_ Nov 13 '19 at 09:23
  • @flaviu2 I am already using that class. My question states that. But thanks. – Andrew Truckle Nov 13 '19 at 09:27
  • Sorry, didn't noticed :) – Flaviu_ Nov 13 '19 at 09:41
  • As Nick said, the only way is to customize yourself by owner-draw. But you will lose the OS theme. You can read this article: http://codexpert.ro/blog/2013/02/22/custom-draw-vs-owner-draw-controls/ – Flaviu_ Nov 13 '19 at 09:53
  • 1
    I saw in romanian forum this (is helpfull): For a CBS_SORT style combobox or listbox owner-draw, respectively LBS_SORT sends the message WM_COMPAREITEM that allows the owner to sort the items. In the MFC, the CompareItem virtual function can be overwritten in the control class. (Taken from here: http://www.codexpert.ro/forum/viewtopic.php?f=30&t=1880) – Flaviu_ Nov 13 '19 at 10:26
  • Thanks @flaviu2. At the moment I have changed my GUI design to use the regular combo with coloured/bold text and I now have a MFC Button with icon on the dialog that changes based on the state of the combo. – Andrew Truckle Nov 13 '19 at 15:04

0 Answers0