CMFCRibbonFontComboBox Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at CMFCRibbonFontComboBox Class.

Implements a combo box that contains a list of fonts. You place the combo box on a ribbon panel.

class CMFCRibbonFontComboBox : public CMFCRibbonComboBox  

Public Constructors

NameDescription
CMFCRibbonFontComboBox::~CMFCRibbonFontComboBoxDestructor.

Protected Constructors

NameDescription
CMFCRibbonFontComboBox::CMFCRibbonFontComboBoxConstructs and initializes a CMFCRibbonFontComboBox object.

Public Methods

NameDescription
CMFCRibbonFontComboBox::BuildFontsPopulates the ribbon font combo box with fonts of the specified font type, character set, and pitch and family.
CMFCRibbonFontComboBox::CreateObjectUsed by the framework to create a dynamic instance of this class type.
CMFCRibbonFontComboBox::GetCharSetReturns the specified character set.
CMFCRibbonFontComboBox::GetFontDesc
CMFCRibbonFontComboBox::GetFontTypeReturns which font types to display in the combo box. Valid options are DEVICE_FONTTYPE, RASTER_FONTTYPE, and TRUETYPE_FONTTYPE, or any bitwise combination thereof.
CMFCRibbonFontComboBox::GetPitchAndFamilyReturns the pitch and the family of the fonts that are displayed in the combo box.
CMFCRibbonFontComboBox::GetThisClassUsed by the framework to obtain a pointer to the CRuntimeClass object that is associated with this class type.
CMFCRibbonFontComboBox::RebuildFontsPopulates the ribbon font combo box with fonts of the previously specified font type, character set, and pitch and family.
CMFCRibbonFontComboBox::SetFontSelects the specified font in the combo box.

After you create a CMFCRibbonFontComboBox object, add it to a ribbon panel by calling CMFCRibbonPanel::Add.

CObject

CMFCRibbonBaseElement

CMFCRibbonButton

CMFCRibbonEdit

CMFCRibbonComboBox

CMFCRibbonFontComboBox

Header: afxRibbonComboBox.h

Populates the combo box on the ribbon with fonts.

void BuildFonts(
    int nFontType = DEVICE_FONTTYPE | RASTER_FONTTYPE | TRUETYPE_FONTTYPE,  
    BYTE nCharSet = DEFAULT_CHARSET,  
    BYTE nPitchAndFamily = DEFAULT_PITCH);

Parameters

[in] nFontType
Specifies the font type of the fonts to add.

[in] nCharSet
Specifies the character set of the fonts to add.

[in] nPitchAndFamily
Specifies the pitch and family of the fonts to add.

Constructs and initializes a CMFCRibbonFontComboBox object.

CMFCRibbonFontComboBox(
    UINT nID,  
    int nFontType = DEVICE_FONTTYPE | RASTER_FONTTYPE | TRUETYPE_FONTTYPE,  
    BYTE nCharSet = DEFAULT_CHARSET,  
    BYTE nPitchAndFamily = DEFAULT_PITCH,  
    int nWidth = -1);

Parameters

[in] nID
The command ID of the command that executes when the user selects an item from the combo box.

[in] nFontType
Specifies which font types to display in the combo box. Valid options are DEVICE_FONTTYPE, RASTER_FONTTYPE, and TRUETYPE_FONTTYPE, or any bitwise combination thereof.

[in] nCharSet
Filters the fonts in the combo box to those that belong to the specified character set..

[in] nPitchAndFamily
Specifies the pitch and the family of the fonts that are displayed in the combo box.

[in] nWidth
Specifies the width, in pixels, of the combo box.

Remarks

For more information about possible nFontType parameter values, see EnumFontFamProc in the Windows SDK documentation.

For more information about valid character sets that can be assigned to nCharSet, and valid values that can be assigned to nPitchAndFamily, see LOGFONT in the Windows SDK documentation.

This topic is included for completeness. For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

const CMFCFontInfo* GetFontDesc(int iIndex = -1) const;  

Parameters

[in] iIndex

Return Value

Remarks

Populates the combo box on the ribbon with fonts of a previously specified font type, character set, and pitch and family.

void RebuildFonts();

Remarks

You can specify the font type, character set, and pitch and family of the fonts to include in the ribbon font combo box in the constructor for this class, or by calling CMFCRibbonFontComboBox::BuildFonts.

Selects the specified font in the combo box.

BOOL SetFont(
    LPCTSTR lpszName,  
    BYTE nCharSet = DEFAULT_CHARSET,  
    BOOL bExact = FALSE);

Parameters

lpszName
Specifies the name of the font to select.

nCharSet
Specifies the character set for the selected font.

bExact
TRUE to specify that the character set must match when selecting a font; FALSE to specify that the character set can be ignored when selecting a font.

Return Value

Nonzero if the specified font was found and selected; otherwise, zero.

Remarks

Returns the specified character set.

BYTE GetCharSet() const;  

Return Value

Character set (see LOGFONT in the Windows SDK documentation).

Remarks

Returns which font types to display in the combo box. Valid options are DEVICE_FONTTYPE, RASTER_FONTTYPE, and TRUETYPE_FONTTYPE, or any bitwise combination thereof.

int GetFontType() const;  

Return Value

Font types (see EnumFontFamProc in the Windows SDK documentation).

Remarks

Returns the pitch and the family of the fonts that are displayed in the combo box.

BYTE GetPitchAndFamily() const;  

Return Value

Pitch and the family (see LOGFONT in the Windows SDK documentation).

Remarks

Hierarchy Chart
Classes
CMFCRibbonComboBox Class

Show: