Cool Font selection combo

This article was contributed by Norm Almond of
Paramax Technology Limited

I came accross a fancy font selection box the other day. It was so cool
I thought I’d copy the idea.

Its basically an imitation of the font selection box found in MS Word,
it has an MRU font list and the other cool feature is that it has a Tooltip window showing
the currently selected font name displayed using the selected font. This gives the user a
sample of what the font is going to look like without actually making a selection.

The main component is an ownerdraw combo with has
strings
flags set, the combo isn’t sorted because the Most
Recently Used font are at  the top of the combo.

The combo is called CFontCombo it is simple to use in dialog boxes, just
follow this simple instructions.

  1. Copy "FontCombo.h" and "TipWnd.h" to your project directory.
  2. Add the files to your project.
  3. Copy the "Printer.bmp" to your project "res" directory.
  4. #include "FontCombo.h" and "TipWnd.h" to the header file of your
    dialog class or to the "stdafx.h"
  5. Using the resource studio Import the printer.bmp and name it IDB_GLYPHS
  6. Using the dialog editor create your combo box and give it the following styles:
    "DropDown", Fixed, "Has Strings", and Verticle Scroll .
  7. Edit the dialogs class header file replace "CComboBox" for CFontCombo
  8. In OnInitDialog before the return statement Add the following line

    m_yourCombo.SubclassDlgItem(IDC_COMBOID,this);

    m_yourCombo.Initialize();

fontcombo.gif (5338 bytes)

Files and resources needed to be included into you own project:

FontCombo.h & cpp

TipWnd.h & cpp,

IDB_GLYPH bitmap resource

Download Source Code

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read