GetFontSelection

Retrieves the current font selection from the specified common dialog box.

BOOL GetFontSelection(
    HWND hDlg,
    LPINT lpHeight,
    LPINT lpWidth,
    LPINT lpFontFamily,
    LPINT lpPitchAndFamily
);

Parameters

Parameter Description
hDlg Handle to the font selection dialog box. This handle is created by the ChooseFont function.
lpHeight Pointer to a 32-bit integer that receives the selected font's height, in logical units.
lpWidth Pointer to a 32-bit integer that receives the selected font's width, in logical units.
lpFontFamily Pointer to a buffer that receives the selected font's typeface name (for example, "Times New Roman"). The buffer must be large enough to hold a LF_FACESIZE character count, including the null terminator.
lpPitchAndFamily Pointer to a 32-bit integer that receives the font's pitch and family. This value can be a combination of pitch, family, and character set values.

Return Value

Value Description
TRUE The function succeeded. The parameters pointed to by lpHeight, lpWidth, lpFontFamily, and lpPitchAndFamily are filled with the corresponding font selection information.
FALSE The function failed. To get extended error information, call GetLastError.

Remarks

You typically call GetFontSelection from within the dialog procedure for the font selection dialog box. When the user clicks the OK button, the dialog procedure sends a WM_COMMAND message with the LOWORD(wParam) equal to IDOK. Your dialog procedure should then call GetFontSelection to retrieve the selected font attributes.

The font height and width are returned in logical units. To convert these values to points, you can use the system metrics obtained by calling the GetSystemMetrics function.

Note: The lpFontFamily parameter receives the typeface name. If you need to get the font characteristics in a LOGFONT structure, you can use the GetCurrentFont function.

Requirements

Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Header CommDlg.h (include Windows.h)
Library Comdlg32.lib
DLL Comdlg32.dll

See Also

ChooseFont
GetCurrentFont
GetSystemMetrics
LOGFONT