Displays the CommDlg control's Font dialog box.
CommDlg.ShowFont
CommDlg.FontName [ = string ]
CommDlg.FontItalic [ = Bool ]
CommDlg.FontBold [ = Bool ]
CommDlg.FontUnderline [ = Bool ]
CommDlg.FontStrikethru [ = Bool ]
CommDlg.FontSize [ = single ]
CommDlg.Font [ = Font ]
CommDlg.PointSize [ = integer ]
CommDlg.FontStyle [ = string ]
CommDlg.Min [ = integer ]
CommDlg.Max [ = integer ]
Before you use the ShowFont method, you must set the Flags property of the CommDlg object to one of three constants or values: cdfBoth (3), cdfPrinterFonts (2), or cdfScreenFonts (1).
The Flags property returns or sets the options for the Font dialog box and can have one or more of the following values.
cdfAnsiOnly $400 - Only fonts that use the Windows character set ( no symbol font).
cdfApply $200 - Enables the Apply button on the dialog box.
cdfBoth $3 - Both printer and screen fonts. The hDC property identifies the device context associated with the printer.
cdfEffects $100 - Enables strikethrough, underline, and color effects.
cdfFixedPitch $400 - 0Only fixed-pitch fonts.
cdfForceFontExists $10000 - An error message box is displayed if the user attempts to select a font or style that doesn't exist.
cdfInitFont $40 - Use GFA-BASIC 32 internal LOGFONT structure to initialize the dialog box controls.
cdfShowHelp $4 - Causes the dialog box to display a Help button.
cdfLimitSize $2000 - Only font with sizes within the range specified by the Min and Max properties.
cdfNoOEMFonts $800 - Don't allow OEM font selections
cdfNoScriptSel $800000 - Disables the Script combo box (only used to initialize the dialog box).
cdfNoFaceSel $80000 - No font name selected.
cdfNoSimulations $1000 - Don't allow graphic device interface (GDI) font simulations.
cdfNoSizeSel $200000 - No font size selected.
cdfNoStyleSel $100000 - No style was selected.
cdfNoVector $800 - Don't allow vector-font selections.
cdfNoVertFonts $1000000 - Don't allow vertical fonts selections.
cdfPrinterFonts $2 - Only the fonts supported by the printer, specified by the hDC property.
cdfScalableOnly $20000 - Only fonts that can be scaled.
cdfScriptsOnly $400 - Allow selection of fonts for all non-OEM and Symbol character sets, as well as the ANSI character set. This supersedes the cdfAnsiOnly value.
cdfScreenFonts $1 - Only the screen fonts supported by the system.
cdfTTOnly $40000 - Only TrueType fonts.
cdfSelectScript $400000 - Only fonts with the character set identified in the lfCharSet member of the internal LOGFONT structure are displayed.
cdfWysiwyg $8000 - Only fonts that are available on both the printer and on screen. If this flag is set, the cdfBoth and cdfScalableOnly flags should also be set.
cdfUseStyle $80 - Use the data in the FontStyle property to initialize the font style combo box. When the dialog is closed the combobox data is copied to FontStyle.
In general, you should change FontName before setting size and style attributes with the FontSize, FontBold, FontItalic, FontStrikethru, and FontUnderline properties. For detailed information: See Also.
The FontStyle [ = string ] property contains the style data ("Bold", "Normal") for the Style combobox of the dialog. The string is a regional setting name.
The PointSize [ = integer ] property specifies the size of the selected font, in units of 1/10 of a point.
The Min property specifies the minimum point size a user can select. The Max property specifies the maximum point size a user can select. ShowFont recognizes this member only if the cdfLimitSize flag is specified.
Ocx CommDlg cd
cd.Flags = cdfScreenFonts | cdfUseStyle | cdfEffects
cd.CancelError = True
Try
cd.ShowFont
ForeColor = cd.Color
Set Me.Font = cd.Font // select font
Print "1234", Me.FontName
Catch
Print "Common dialog box canceled!"
EndCatch
Do
Sleep
Until Me Is Nothing
CommDlg, Dlg Font, Font, FontSize, FontBold, FontItalic, FontStrikethru, FontUnderline
{Created by Sjouke Hamstra; Last updated: 23/10/2014 by James Gaite}