How to set font in edit box part of a CMFCToolBarComboBoxButton?

130 Views Asked by At

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.

1

There are 1 best solutions below

0
On

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.