Date: 02-16-2022
Return to Index
created by gbSnippets
'PowerBASIC has a built-in DDT command to access the Windows font selection dialog
'Primary Code:
'Syntax: DISPLAY FONT [hParent], [xpos], [ypos], defname$, defpoints&, _
'defstyle&, flags& TO fontname$, points&, style& [,color&, charset&]
Display Font hParent, 100,100, defname$, defpoints&, defstyle&, flags& To _
fontName$, points&, style&, color&, charset&
'Flag Options:
%CF_BOTH 'Screen and printer fonts displayed.
%CF_TTONLY 'TrueType fonts only.
%CF_EFFECTS 'Enable strikeout, underline, and color effects.
%CF_FIXEDPITCHONLY 'Display on fixed-pitch fonts.
%CF_FORCEFONTEXIST 'Only allows selection existing fonts.
%CF_NOSTYLESEL 'Dialog has no initial style selection.
%CF_NOSIZESEL 'Dialog has no initial size selection.
%CF_NOSIMULATIONS 'Does not display GDI font simulations.
%CF_NOVECTORFONTS 'Does not allow vector font selections.
%CF_PRINTERFONTS 'Display only fonts supported by the printer.
%CF_SCALABLEONLY 'Only allow selection of scalable fonts.
%CF_SCREENFONTS 'Lists only screen fonts supported by OS.
%CF_WYSIWYG 'Only allow selection fonts available on both the printer and
'the display (must set %CF_BOTH and %CF_SCALABLEONLY flags).
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
Global hDlg As DWord
Function PBMain() As Long
Local hParent as DWord, defname$, defpoints&, defstyle&, flags& 'Input variables
Local fontname$, points&, style&, color&, charset& 'TO variables
hParent = hDlg
defname$ = "Arial"
defpoints& = 8
defstyle& = 0 Or 1 '0-normal 1-bold 2-italic 4-underline 8-strikeout
flags& = %CF_Both Or %CF_ForceFontExist Or %CF_InitToLogFontStruct Or %CF_NoScriptSel
Display Font hParent, 100,100, defname$, defpoints&, defstyle&, flags& To _
fontName$, points&, style&, color&, charset&
If Len(fontName$) Then
MsgBox fontName$
Else
MsgBox "No font name selected!" 'ESC or Cancel
End If
End Function
'gbs_00117
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm