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 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


Comments

  • combobox limi

    Posted by Legacy on 10/17/2002 12:00am

    Originally posted by: venu

    hi
    in combobox is there any no of items limit.
    thanks for your help

    from
    venu

    Reply
  • Change height of selection box in wner drawn combobox

    Posted by Legacy on 06/01/2001 12:00am

    Originally posted by: martin

    Hi,
    Great class, thanks.
    My question: owner drawn combo boxes are bigger than the regular combo box. So if I was to put a regular combobox next to yours to select font size, it would look bad because it's height is less. Is there any way to change the height of the custom combobox (I am refering no to the height where the list appears, but to the box where the selection appears)
    Cheers,
    Martin

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Hurricane Sandy was one of the most destructive natural disasters that the United States has ever experienced. Read this success story to learn how Datto protected its partners and their customers with proactive business continuity planning, heroic employee efforts, and the right mix of technology and support. With storm surges over 12 feet, winds that exceeded 90 mph, and a diameter spanning more than 900 miles, Sandy resulted in power outages to approximately 7.5 million people, and caused an estimated $50 …

  • The impact of a data loss event can be significant. Real-time data is essential to remaining competitive. Many companies can no longer afford to rely on a truck arriving each day to take backup tapes offsite. For most companies, a cloud backup and recovery solution will eliminate, or significantly reduce, IT resources related to the mundane task of backup and allow your resources to be redeployed to more strategic projects. The cloud - can now be comfortable for you – with 100% recovery from anywhere all …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds