Lfheight as Long
Lfwidth as Long
Lfescapement as Long
Lforientation as Long
Lfweight as Long
Lfitalic as Byte
Lfunderline as Byte
Lfstrikeout as Byte
lfCharSet as Byte
Lfoutprecision as Byte
Lfclipprecision as Byte
Lfquality as Byte
Lfpitchandfamily as Byte
Lffacename as String * 31
End Type
Private Type Choosefont
lStructSize as Long
hWndOwner as Long ' caller ' s window handle
HDC as Long ' printer Dc/ic or NULL
lpLogFont as Long ' ptr. to a logfont struct
Ipointsize as Long ' * size in points of selected font
Flags as Long ' enum. Type flags
Rgbcolors as Long ' returned text color
Lcustdata as Long ' data passed to hook FN.
Lpfnhook as Long ' ptr. To hook function
Lptemplatename as String ' custom template name
HInstance as Long ' instance handle of. EXE that
' Contains Cust. Dlg. Template
Lpszstyle as String ' return to the style field here
' must be lf_facesize or bigger
nFontType as Integer ' same value reported to the Enumfonts
' Call back with the extra fonttype_
' bits added
Missing_alignment as Integer
Nsizemin as Long ' minimum pt size allowed &
Nsizemax as Long ' max PT size allowed if
' Cf_limitsize is used
End Type
Private Declare Function choosefont Lib "Comdlg32.dll" Alias "Choosefonta" _
(ByRef Pchoosefont as Choosefont) As Long
Private Sub Command1_Click ()
Dim CF as Choosefont, Lfont as LogFont
Dim FontName as String, ret as Long
Cf.flags = Cf_both or cf_effects or cf_forcefontexist or cf_inittologfontstruct or cf_limitsize
Cf.lplogfont = VarPtr (Lfont)
Cf.lstructsize = LenB (CF)
' cf.lstructsize = Len (cf) ' size of structure
Cf.hwndowner = Form1.hwnd ' window Form1 is opening this dialog box
CF.HDC = Printer.hdc ' device context of default Printer (using VB ' s mechanism)
cf.rgbcolors = RGB (0, 0, 0) ' Black
Cf.nfonttype = Regular_fonttype ' REGULAR font type i.e. not bold or anything
Cf.nsizemin = Ten ' minimum point size
Cf.nsizemax = maximum point size
ret = choosefont (CF) ' brings up the font dialog
IF ret <> 0 Then ' success
FontName = StrConv (Lfont.lffacename, Vbunicode, &h804) ' Retrieve Chinese font name in 中文版 version os
FontName = left$ (FontName, INSTR (1, FontName, vbNullChar)-1)
' Assign the font properties to Text1
With Text1.font
. Charset = Lfont.lfcharset ' Assign Charset to font
. Name = FontName
. Size = CF.IPOINTSIZE/10 ' Assign point size
Text1.Text =. Name & ":" &. Charset & ":" &. Size ' Display data in chosen Font
End With
End If
End Sub
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.