1

I'm able to set the font used to draw the drop-down part of a CMFCToolBarComboBoxButton combo box which is embedded in a CMFCToolBar toolbar. However, I'm not able to set/change the font used for the edit field control which is part of the combo box. I.e., when the combo box is collapsed the currently selected item is always drawn with the standard/default font no matter what font is used for the entries when expanding the box.

I successfully change the font of the drop down box part by using a pointer to the underlying CComboBox object retrieved via CMFCToolBarComboBoxButton::GetComboBox() (and then via CComboBox::SetFont(...)). But when using the method CMFCToolBarComboBoxButton::GetEditCtrl() to obtain a pointer to the edit control part (in order to change its font, too) this method always returns a nulltpr. Does anybody know why or more importantly: What is the correct way to set the font used for the edit control part of the box?

I've searched the web now quite a lot but cannot find a solution to the problem. Thanks for any advice!

Additional note: I need to change the used font(s) at run time in my MFC application.

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
Friggle
  • 11
  • 3
  • It would be better to provide a small snippet of code that shows what you are doing right now so others can test it. One thing that comes to my mind it, is the font is question still "valid"? For example, are you creating a font locally and then it going out of scope? There is not enough information to see. – Andrew Truckle Jan 02 '23 at 16:40
  • Is this of drop-down, drop-list etc or editable style? What exactly? – Constantine Georgiou Jan 02 '23 at 19:38

1 Answers1

0

OK, I finally came to the conclusion that it's better to leave these fonts up to the OS settings anyway and not explicitly set them by the application code. This is not a technically correct answer to the (my own) question, certainly, but may be a good advide for others chasing the same problem.

Friggle
  • 11
  • 3