CMFCToolBarFontSizeComboBox Class
A toolbar button that contains a combo box control that enables the user to select a font size.
Syntax
class CMFCToolBarFontSizeComboBox : public CMFCToolBarComboBoxButton
Members
Protected Constructors
Name | Description |
---|---|
CMFCToolBarFontSizeComboBox::CMFCToolBarFontSizeComboBox | Constructs a CMFCToolBarFontSizeComboBox object. |
Public Methods
Name | Description |
---|---|
CMFCToolBarFontSizeComboBox::GetTwipSize | Returns the selected font size in twips. |
CMFCToolBarFontSizeComboBox::RebuildFontSizes | Fills the combo box list with all supported font sizes for a specified font. |
CMFCToolBarFontSizeComboBox::SetTwipSize | Sets the font size in twips. |
Remarks
You can use a CMFCToolBarFontSizeComboBox
object together with a CMFCToolBarFontComboBox Class object to enable a user to select a font and font size.
You can add a font size combo box button to a toolbar just as you add a font combo box button. For more information, see CMFCToolBarFontComboBox Class.
When the user selects a new font in a CMFCToolBarFontComboBox
object, you can fill the font size combo box with the supported sizes for that font by using the CMFCToolBarFontSizeComboBox::RebuildFontSizes method.
Example
The following example demonstrates how to use various methods in the CMFCToolBarFontSizeComboBox
class to configure a CMFCToolBarFontSizeComboBox
object. The example illustrates how to retrieve the font size, in twips, from the text box, fill the font size combo box with all valid sizes of the given font, and specify the font size in twips. This code snippet is part of the Word Pad sample.
CMFCToolBarFontSizeComboBox *pSizeCombo =
DYNAMIC_DOWNCAST(CMFCToolBarFontSizeComboBox, CMFCToolBarFontSizeComboBox::GetByCmd(IDC_FONTSIZE));
if (pSizeCombo != NULL)
{
int nSize = pSizeCombo->GetTwipSize();
// CMFCFontInfo* pDesc
pSizeCombo->RebuildFontSizes(pDesc->m_strName);
pSizeCombo->SetTwipSize(nSize);
}
Inheritance Hierarchy
Requirements
Header: afxtoolbarfontcombobox.h
CMFCToolBarFontSizeComboBox::CMFCToolBarFontSizeComboBox
Constructs a CMFCToolBarFontSizeComboBox
object.
CMFCToolBarFontSizeComboBox();
CMFCToolBarFontSizeComboBox::GetTwipSize
Retrieves the font size, in twips, from the text box of a font size combo box.
int GetTwipSize() const;
Return Value
If the return value is positive, it is the font size in twips. It is -1 if the text box of the combo box is empty. It is -2 if an error occurs.
CMFCToolBarFontSizeComboBox::RebuildFontSizes
Fills a font size combo box with all valid sizes of the given font.
void RebuildFontSizes(const CString& strFontName);
Parameters
strFontName
[in] Specifies a font name.
Remarks
Call this function when you want to synchronize between selection in a font combo box and a font size combo box, such as a CMFCToolBarFontComboBox Class.
CMFCToolBarFontSizeComboBox::SetTwipSize
Rounds the specified size (in twips) to the nearest size in points, and then sets the selected size in the combo box to that value.
void SetTwipSize(int nSize);
Parameters
nSize
[in] Specifies the font size (in twips) to set.
Remarks
You can retrieve the previous valid font size later by calling the CMFCToolBarFontSizeComboBox::GetTwipSize method.
See also
Hierarchy Chart
Classes
CMFCToolBar Class
CMFCToolBarButton Class
CMFCToolBarComboBoxButton Class
CMFCFontInfo Class
CMFCToolBar::ReplaceButton
Walkthrough: Putting Controls On Toolbars