Fonts Hot ComboBox | CodeGuru

Fonts Hot ComboBox

Editor’s Note: The ComboBox used in this article is illustrated in Alan’s Hot Combo Box Control article. I had an application where I wanted to allow the user to change fonts but I was not happy with the default CFontDialog provided by the MFC framework. For one it just looks like any old application and […]

Written By
CodeGuru Staff
CodeGuru Staff
Jan 19, 2001
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More


Editor’s Note: The ComboBox used in this article is illustrated
in Alan’s Hot Combo Box Control article.

I had an application where I wanted to allow the user to
change fonts but I was not happy with the default CFontDialog provided by the
MFC framework. For one it just looks like any old application and I like my
applications to stand out. Secondly, it means that the user has to go to another
dialog box and click on each font in turn until they find one that they wish
to use.

So I figured; why not develop my own font selection combo
box like that in Word and similar applications?

I published an article a while ago which delivered a combo
box which becomes three-dimensional when the mouse moves over it or it has
focus. This article includes the technology in my previous article to make
this combo box a little more special.

The hot font combo box is derived from the standard combo
box so it can be used easily in VC++ dialogs etc. without any subclassing or
complex code. Simply create a new class in the ClassWizard called CHotFontCombo,
derived from CComboBox. Then overwrite the files for that class
(HotFontCombo.cpp and HotFontCombo.h) with the files from this article.

Then to create an instance of the hot font combo box
simply add a combo box to your dialog resource, then create a member variable
of type CHotFontCombo. The MFC framework does all the subclassing for you.

Then, in the OnInitDialog function of you dialog box call
the InitialiseFontList() member of the combo box and you will have a gorgeous
font selection combo. Heres how it looks:



Then when dropped down…



…each entry is drawn in its own font

Downloads

Download source – 3 Kb
Download demo project – 80 Kb

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.