Adds the available sizes of a font to the combo box control.
C
BOOL WINAPI SftBox_FontSizes(HWND hwndCtl, HDC hDCParm, LPCTSTR lpszFont);
C++
BOOL CSftBox::FontSizes(HDC hDCParm, LPCTSTR lpszFont);
hwndCtl
The window handle of the combo box control.
hDCParm
The device context of an output device, typically a printer. The sizes available for this device are added in addition to the sizes available for the display. This parameter may be NULL, in which case only the sizes available for the display are added.
lpszFont
The font name (typeface name) of the font whose sizes are to be added.
The return value is TRUE if the combo box contains at least one item once the sizes have been added, otherwise FALSE is returned.
The FontSizes function adds the available sizes of a font to the combo box control.
One item is added for each size. The text of the first column (column 0) is the font size in points. The size is also saved as cell data of the first column. It can be retrieved using GetCellInfo (SFTBOX_CELL, cellData).
The sizes added depend on the font type:
| Font Type | Sizes |
|---|---|
| TrueType font | All existing items are removed, then the sizes 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48 and 72 are added. |
| Vector font | All existing items are removed, then the sizes 6, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48 and 72 are added. |
| Raster font | The sizes in which the font is available are added. Existing items are not removed. Each size is inserted in ascending order and is added only once, based on the cell data of the existing items. |
Because existing items are not removed for a raster font, use ResetContent to remove all items before adding the sizes of another font.
The Fonts function adds the available font names to a combo box. The FontStyles function adds the available styles of a font.
LONG total;
// Add font sizes to combo box, based on selected font
// clear (in case of refresh)
SftBox_ResetContent(m_hwndSizes);
// Add font sizes
SftBox_FontSizes(m_hwndSizes, m_hDC, lpszFont);
SftBox_RecalcHorizontalExtent(m_hwndSizes, -1);
SortSizes();
// try to find the closest match to the last size selected,
// the cell data of each item is the font size
int diff = 9999;
// Add font sizes to combo box, based on selected font
// clear (in case of refresh)
m_Sizes.ResetContent();
// Add font sizes
m_Sizes.FontSizes(m_hDC, lpszFont);
m_Sizes.RecalcHorizontalExtent(-1);
SortSizes();
// try to find the closest match to the last size selected,
// the cell data of each item is the font sizeSee Also C/C++ API | Categories | Notifications