CHOOSEFONT

typedef struct { /* cf */

DWORD lStructSize;

HWND hwndOwner;

HDC hDC;

LPLOGFONT lpLogFont;

int iPointSize;

DWORD Flags;

DWORD rgbColors;

DWORD lCustData;

LPCFHOOKPROC lpfnHook;

LPSTR lpTemplateName;

HANDLE hInstance;

LPSTR lpszStyle;

WORD nFontType;

int nSizeMin;

int nSizeMax;

} CHOOSEFONT;

The CHOOSEFONT structure contains information that the system uses to initialize the system-defined font selection dialog box. After the user dismisses the dialog box, the system returns information about the user's selection in this structure.

Members

lStructSize

Specifies the length of the structure (in bytes).

hwndOwner

Identifies the window that owns the dialog box. This member can be any valid window handle, or NULL if the dialog box has no owner.

hDC

Identifies the device context (or information context) of the printer whose fonts will be listed in the dialog box. This member is only used if the Flags member specifies the CF_PRINTERFONTS flag; otherwise, this member is ignored.

lpLogFont

Points to a LOGFONT structure. If an application initializes the members of this structure before calling ChooseFont and also sets the CF_INITTOLOGFONTSTRUCT flag, the ChooseFont function will initialize the dialog with a font that is the closest possible match. After the user dismisses the dialog, the ChooseFont function will set the members of the LOGFONT structure based on the user's final selection.

iPointSize

Specifies the size of the selected font in units of 1/10 of a point. The ChooseFont function sets this value after the user dismisses the dialog.

Flags

Specifies the dialog-box initialization flags. This member may be a combination of the following values:

Value Meaning

CF_APPLY Specifies that the ChooseFont function should enable the Apply button.
CF_ANSIONLY Specifies that the ChooseFont function should only allow the selection of fonts which use the ANSI character set. (If this flag is set, the user will not be able to select a font that only contains symbols.)
CF_BOTH Causes the dialog box to list the available printer and screen fonts. The hDC member identifies the device context (or information context) associated with the printer.
CF_TTONLY Specifies that the ChooseFont function should only enumerate and allow the selection of TrueType fonts.
CF_EFFECTS Specifies that the ChooseFont function should enable strikeout, underline, and color effects. If this flag is set, the lfStrikOut, lfUnderline, and rgbColors members may be set before calling ChooseFont. And, if this flag is set, the ChooseFont function may set these members after the user dismisses the dialog.
CF_ENABLEHOOK Enables the hook function specified in the lpfnHook member of this structure.
CF_ENABLETEMPLATE Indicates that the hInstance member identifies a data block that contains a dialog template which is identified by lpTemplateName.
CF_ENABLETEMPLATEHANDLE Indicates that the hInstance member identifies a data block that contains a pre-loaded dialog template. The system ignores the lpTemplateName member if this flag is specified.
CF_FIXEDPITCHONLY Specifies that the ChooseFont function should only select fixed-pitch fonts.
CF_FORCEFONTEXIST Specifies that the ChooseFont function should indicate an error condition if the user attempts to select a font or style which does not exist.
CF_INITTOLOGFONTSTRUCT Specifies that the ChooseFont function should use the LOGFONT structure at which lpLogFont points to initialize the dialog controls.
CF_LIMITSIZE Specifies that the ChooseFont function should only select font sizes within the range specified by the nSizeMin and nSizeMax fields.
CF_NOSIMULATIONS Specifies that the ChooseFont function should not allow GDI font simulations.
CF_NOVECTORFONTS Specifies that the ChooseFont function should not allow vector-font selections.
CF_PRINTERFONTS Causes the dialog box to only list the fonts supported by the printer associated with device context (or information context) identified by the hDC member.
CF_SCALABLEONLY Specifies that the ChooseFont function should only allow the selection of scalable fonts. (Scalable fonts include: vector fonts, scalable printer fonts, TrueType fonts, and fonts which are scaled by other algorithms or technologies.)
CF_SCREENFONTS Causes the dialog box to only list the screen fonts supported by the system.
CF_SHOWHELP Causes the dialog box to show the Help push button. The hwndOwner must not be NULL if this option is specified.
CF_USESTYLE Specifies that the lpszStyle member points to a buffer which contains style data that the ChooseFont function should use to initialize the Font Style selection. When the user dismisses the dialog, the ChooseFont function will copy style data for the user's selection to this buffer.
CF_WYSIWYG Specifies that the ChooseFont function should only allow the selection of fonts which are available on both the printer and the display. If this flag is set, the CF_BOTH and CF_SCALABLEONLY flags should also be set.

rgbColors

If the CF_EFFECTS flag is set, this field contains an RGB value which the ChooseFont function should use to set the text color. After the user dismisses the dialog, this field contains the RGB value of the color which the user selected.

lCustData

Specifies application-defined data that the application passes to the hook function.

lpfnHook

Points to a hook function that processes messages intended for the dialog box. An application must specify the CF_ENABLEHOOK function in the Flags member to enable the function; otherwise, the system ignores this member. The hook function must return FALSE to pass a message on to the standard dialog procedure, or TRUE to discard the message.

lpTemplateName

Points to a null-terminated string that names the dialog box template resource to be substituted for the standard dialog template. An application can use the MAKEINTRESOURCE macro for numbered dialog resources. This member is only used if the Flags member specifies the CF_ENABLETEMPLATE flag; otherwise, this member is ignored.

hInstance

Identifies a data block that contains the dialog template specified by the lpstrTemplateName member. This member is only used if the Flags member specifies the CF_ENABLETEMPLATE flag; otherwise, this member is ignored.

lpszStyle

Points to a buffer which contains style data. If the CF_USESTYLE flag is set, the ChooseFont function uses the data in this buffer to initialize the style control. When the user dismisses the dialog, the ChooseFont function copies the string in the style control into this buffer.

nFontType

Specifies the type of the selected font. This field may contain one of the values in the following list:

Value Meaning

SIMULATED_FONTTYPE Specifies that the font is simulated by GDI.
PRINTER_FONTTYPE Specifies that the font is a printer font.
SCREEN_FONTTYPE Specifies that the font is a screen font.

nSizeMin

Specifies the minimum point size that a user can select. The ChooseFont function will only recognize this field if the CF_LIMITSIZE flag is set.

nSizeMax

Specifies the maximum point size that a user can select. The ChooseFont function will only recognize this field if the CF_LIMITSIZE flag is set.

See Also

ChooseFont