CHOOSEFONT (structure)
A version of this page is also available for
4/8/2010
This structure contains information that ChooseFont (function) uses to initialize the Font dialog box. After the user closes the dialog box, the system returns information about the selection that the user made in this structure.
Syntax
typedef struct tagCHOOSEFONT {
DWORD lStructSize;
HWND hwndOwner;
HDC hDC;
LPLOGFONTW lpLogFont;
INT iPointSize;
DWORD Flags;
COLORREF rgbColors;
LPARAM lCustData;
LPCFHOOKPROC lpfnHook;
LPCWSTR lpTemplateName;
HINSTANCE hInstance;
LPWSTR lpszStyle;
WORD nFontType;
WORD ___MISSING_ALIGNMENT__;
INT nSizeMin;
INT nSizeMax;
} CHOOSEFONTW, *LPCHOOSEFONTW;
Members
- lStructSize
DWORD that specifies the size, in bytes, of the structure.
- hwndOwner
Handle to the window that owns the dialog box. This member can be any valid window handle, or this member can be NULL if the dialog box has no owner.
- hDC
Handle to the device context or information context of the printer for which fonts should be listed in the dialog box. ChooseFont uses this member only if the Flags member specifies CF_PRINTERFONTS or CF_BOTH; otherwise, ChooseFont ignores this member.
- lpLogFont
Pointer to a LOGFONT structure. If you set the Flags member to CF_INITTOLOGFONTSTRUCT and initialize the LOGFONT members, the ChooseFont function initializes the dialog box with a font that is the closest possible match to your specifications. If the user chooses the OK button, ChooseFont sets the members of the LOGFONT structure based on the selections that the user made.
- iPointSize
Integer that contains the size of the selected font, in tenths of a point. The ChooseFont function sets this value after the user closes the dialog box.
Flags
DWORD that contains a set of bit flags that you can use to initialize the Font dialog box. Upon return, the dialog box sets these flags to indicate the input that the user provided. The following table shows the possible values.Value Description CF_APPLY
Causes the dialog box to display the Apply button. You should provide a hook procedure to process WM_COMMAND messages for the Apply button.
CF_BOTH
Causes the dialog box to list the available printer and screen fonts. The hDC member is a handle to the device context or information context associated with the printer. This value is a combination of the CF_SCREENFONTS and CF_PRINTERFONTS values.
CF_EFFECTS
Causes the dialog box to display the controls that allow the user to specify strikeout, underline, and text color options. If you set this value, you can use the rgbColors member to specify the initial text color. You can use the lfStrikeOut and lfUnderline members of the LOGFONT structure pointed to by lpLogFont to specify the initial settings of the strikeout and underline check boxes. ChooseFont can use these members to return the selections that the user makes.
CF_ENABLEHOOK
Enables the hook procedure specified in the lpfnHook member of this structure.
CF_ENABLETEMPLATE
Indicates that the hInstance and lpTemplateName members specify a dialog box template to use in place of the default template.
CF_ENABLETEMPLATEHANDLE
Indicates that the hInstance member identifies a data block that contains a preloaded dialog box template. The OS ignores the lpTemplateName member if you specify this value.
CF_FIXEDPITCHONLY
Specifies that ChooseFont should select only fixed-pitch fonts.
CF_FORCEFONTEXIST
Specifies that ChooseFont should indicate an error condition if the user attempts to select a font or style that does not exist.
CF_INITTOLOGFONTSTRUCT
Specifies that ChooseFont should use the LOGFONT structure pointed to by the lpLogFont member to initialize the dialog box controls.
CF_LIMITSIZE
Specifies that ChooseFont should select only font sizes within the range specified by the nSizeMin and nSizeMax members.
CF_NOFACESEL
Prevents the dialog box from displaying an initial selection for the Font combo box. You can use this value selectively when you use a LOGFONT structure to initialize the dialog box controls if no single font name applies to the text selection.
CF_NOOEMFONTS
Same as the CF_NOVECTORFONTS value.
CF_NOSCRIPTSEL
Disables the Script combo box. When you set this value, the lfCharSet member of the LOGFONT structure is set to DEFAULT_CHARSET when ChooseFont returns. Use this value only to initialize the dialog box.
CF_NOSIMULATIONS
Specifies that ChooseFont should not allow graphics device interface (GDI) font simulations.
CF_NOSIZESEL
Prevents the dialog box from displaying an initial selection for the Size combo box. Use this value selectively when you use a LOGFONT structure to initialize the dialog box controls if no single font size applies to the text selection.
CF_NOSTYLESEL
Prevents the dialog box from displaying an initial selection for the Font Style combo box. Use this value selectively when you use a LOGFONT structure to initialize the dialog box controls if no single font style applies to the text selection.
CF_NOVECTORFONTS
Specifies that ChooseFont should not allow vector font selections.
CF_NOVERTFONTS
Causes the Font dialog box to list only horizontally oriented fonts.
CF_PRINTERFONTS
Causes the dialog box to list only the fonts supported by the printer associated with the device context or information context that you specified in the hDC member.
CF_SCALABLEONLY
Specifies that ChooseFont should allow only the selection of scalable fonts. Scalable fonts include vector fonts, scalable printer fonts, TrueType fonts, and fonts scaled by other technologies.
CF_SCREENFONTS
Causes the dialog box to list only the screen fonts that the OS supports.
CF_SCRIPTSONLY
Specifies that ChooseFont should allow the selection of fonts for all non-OEM and Symbol character sets, as well as the ANSI character set.
CF_SELECTSCRIPT
Displays only fonts with the character set identified in the lfCharSet member of the LOGFONT structure, when specified on input. The user cannot change the character set specified in the Scripts combo box.
CF_TTONLY
Specifies that ChooseFont should only enumerate and allow the selection of TrueType fonts.
CF_USESTYLE
Specifies that the lpszStyle member is a pointer to a buffer that contains style data that ChooseFont should use to initialize the Font Style combo box. When the user closes the dialog box, ChooseFont copies style data for the selection that the user made to this buffer.
CF_WYSIWYG
Specifies that ChooseFont should allow only the selection of fonts available on both the printer and the display. If you specify this value, you should also specify the CF_BOTH and CF_SCALABLEONLY values.
- rgbColors
Value of the COLORREF type, which contains the color of the text. If the Flags member contains CF_EFFECTS, rgbColors specifies the initial text color. When ChooseFont returns successfully, rgbColors contains the red, green, and blue values of the text color that the user selected. To create a COLORREF color value, use the RGB macro.
- lCustData
LPARAM that specifies application-defined data that the OS passes to the hook procedure that you specified in the lpfnHook member. When the OS sends the WM_INITDIALOG message to the hook procedure, the lParam parameter of the message is a pointer to CHOOSEFONT (structure) specified when the application created the dialog box. The hook procedure can use this pointer to get the value of the lCustData member.
- lpfnHook
Pointer to a CFHookProc hook procedure that can process messages intended for the dialog box. ChooseFont ignores lpfnHook unless the Flags member contains CF_ENABLEHOOK.
- lpTemplateName
Pointer to a null-terminated string that names the dialog box template resource in the module identified by the hInstance member. ChooseFont substitutes this template for the standard dialog box template. For numbered dialog box resources, lpTemplateName can be a value returned by the MAKEINTRESOURCE macro. ChooseFont ignores lpTemplateName unless the Flags member contains CF_ENABLETEMPLATE.
- hInstance
Handle to an instance of an executable that contains the custom dialog box template. If the Flags member contains CF_ENABLETEMPLATEHANDLE, hInstance is a handle to a memory object that contains a dialog box template. If Flags contains CF_ENABLETEMPLATE, hInstance is a handle to a module that contains a dialog box template that the lpTemplateName member names. If Flags contains neither CF_ENABLETEMPLATEHANDLE nor CF_ENABLETEMPLATE, ChooseFont ignores this member.
- lpszStyle
Pointer to a buffer that contains style data. If Flags contains the CF_USESTYLE flag, ChooseFont uses the data in this buffer to initialize the Font Style combo box. When the user closes the dialog box, ChooseFont copies the string in the Font Style combo box into this buffer.
nFontType
WORD that receives the type of the font that the user selected when ChooseFont returns. The following table shows the possible values.Value Description BOLD_FONTTYPE
The font weight is bold. This information is duplicated in the lfWeight member of the LOGFONT structure and is equivalent to FW_BOLD.
ITALIC_FONTTYPE
The italic font attribute is set. This information is duplicated in the lfItalic member of the LOGFONT structure.
PRINTER_FONTTYPE
The font is a printer font.
REGULAR_FONTTYPE
The font weight is standard. This information is duplicated in the lfWeight member of the LOGFONT structure and is equivalent to FW_REGULAR.
SCREEN_FONTTYPE
The font is a screen font.
SIMULATED_FONTTYPE
The font is simulated by the graphics device interface (GDI).
- ___MISSING_ALIGNMENT__
Not used.
- nSizeMin
Integer that specifies the minimum point size a user can select. ChooseFont recognizes this member only if Flags contains CF_LIMITSIZE.
- nSizeMax
Integer that specifies the maximum point size a user can select. ChooseFont recognizes this member only if Flags contains CF_LIMITSIZE.
Requirements
Header | commdlg.h |
Windows Embedded CE | Windows CE .NET 4.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |
See Also
Reference
Common Dialog Boxes Structures
COLORREF
CFHookProc
ChooseFont (function)
MAKEINTRESOURCE
RGB
WM_COMMAND
WM_INITDIALOG