The ChooseFont function creates a Font common dialog box that enables the user to choose attributes for a logical font. These attributes include a typeface name, style (bold, italic, or regular), point size, effects (underline, strikeout, and text color), and a script (or character set).
BOOL ChooseFont(
LPCHOOSEFONT lpcf |
// pointer to structure with initialization data |
); |
If the user clicks the OK button of the dialog box, the return value is nonzero. The members of the CHOOSEFONT structure indicate the user’s selections.
If the user cancels or closes the Font dialog box or an error occurs, the return value is zero. To get extended error information, call the CommDlgExtendedError function, which can return one of the following values:
CDERR_FINDRESFAILURE |
CDERR_NOHINSTANCE |
CDERR_INITIALIZATION |
CDERR_NOHOOK |
CDERR_LOCKRESFAILURE |
CDERR_NOTEMPLATE |
CDERR_LOADRESFAILURE |
CDERR_STRUCTSIZE |
CDERR_LOADSTRFAILURE |
CFERR_MAXLESSTHANMIN |
CDERR_MEMALLOCFAILURE |
CFERR_NOFONTS |
CDERR_MEMLOCKFAILURE |
You can provide a CFHookProc hook procedure for a Font dialog box. The hook procedure can process messages sent to the dialog box. To enable a hook procedure, set the CF_ENABLEHOOK flag in the Flags member of the CHOOSEFONT structure and specify the address of the hook procedure in the lpfnHook member.
The hook procedure can send the WM_CHOOSEFONT_GETLOGFONT, WM_CHOOSEFONT_SETFLAGS, and WM_CHOOSEFONT_SETLOGFONT messages to the dialog box to get and set the current values and flags of the dialog box.
CFHookProc, CHOOSEFONT, CommDlgExtendedError, LOGFONT, WM_CHOOSEFONT_GETLOGFONT, WM_CHOOSEFONT_SETFLAGS, WM_CHOOSEFONT_SETLOGFONT