BOOL ChooseFont(lpcf) | |||||
LPCHOOSEFONT lpcf; | /* pointer to structure with initialization data | */ |
The ChooseFont function creates a system-defined dialog box from which the user can select a font, a font style (such as bold or italic), a point size, an effect (such as strikeout or underline), and a color.
lpcf
Points to a CHOOSEFONT structure that initially contains information necessary to initialize the dialog box. When the ChooseFont function returns, this structure contains information about the user's font selection. The CHOOSEFONT structure has the following form:
#include <commdlg.h>
typedef struct tagCHOOSEFONT { /* cf */
DWORD lStructSize;
HWND hwndOwner;
HDC hDC;
LOGFONT FAR* lpLogFont;
int iPointSize;
DWORD Flags;
COLORREF rgbColors;
LPARAM lCustData;
UINT (CALLBACK* lpfnHook)(HWND, UINT, WPARAM, LPARAM);
LPCSTR lpTemplateName;
HINSTANCE hInstance;
LPSTR lpszStyle;
UINT nFontType;
int nSizeMin;
int nSizeMax;
} CHOOSEFONT;
The return value is TRUE if the function is successful. Otherwise, it is FALSE.
Use the CommDlgExtendedError function to retrieve the error value, which may be one of the following:
CDERR_FINDRESFAILURE
CDERR_INITIALIZATION
CDERR_LOCKRESFAILURE
CDERR_LOADRESFAILURE
CDERR_LOADSTRFAILURE
CDERR_MEMALLOCFAILURE
CDERR_MEMLOCKFAILURE
CDERR_NOHINSTANCE
CDERR_NOHOOK
CDERR_NOTEMPLATE
CDERR_STRUCTSIZE
CFERR_MAXLESSTHANMIN
CFERR_NOFONTS