Partager via


CMFCToolBarFontComboBox Class

A toolbar button that contains a combo box control that enables the user to select a font from a list of system fonts.

class CMFCToolBarFontComboBox : public CMFCToolBarComboBoxButton

Members

Protected Constructors

Name

Description

CMFCToolBarFontComboBox::CMFCToolBarFontComboBox

Constructs a CMFCToolBarFontComboBox object.

Public Methods

Name

Description

CMFCToolBarFontComboBox::GetFontDesc

Returns a pointer to the CMFCFontInfo object for a specified index in the combo box.

CMFCToolBarFontComboBox::SetFont

Selects a font in the font combo box according to either the name of the font, or the prefix and character set of the font.

Data Members

Remarks

To add a font combo box button to a toolbar, follow these steps:

  1. Reserve a dummy resource ID for the button in the parent toolbar resource.

  2. Construct a CMFCToolBarFontComboBox object.

  3. In the message handler that processes the AFX_WM_RESETTOOLBAR message, replace the original button with the new combo box button by using CMFCToolBar::ReplaceButton.

  4. Synchronize the font that is selected in the combo box with the font in the document by using the CMFCToolBarFontComboBox::SetFont method.

To synchronize the document's font with the font selected in the combo box, use the CMFCToolBarFontComboBox::GetFontDesc method to retrieve the attributes of the selected font, and use those attributes to create a CFont Class object.

The font combo box button calls the Win32 function EnumFontFamiliesEx to determine the screen and printer fonts available to the system.

Inheritance Hierarchy

CObject

   CMFCToolBarButton

      CMFCToolBarComboBoxButton

         CMFCToolBarFontComboBox

Requirements

Header: afxtoolbarfontcombobox.h

See Also

Tasks

Walkthrough: Putting Controls On Toolbars

Reference

Hierarchy Chart

CMFCToolBar Class

CMFCToolBarButton Class

CMFCToolBarComboBoxButton Class

CMFCFontInfo Class

CMFCToolBar::ReplaceButton

Other Resources

MFC Classes