国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

VB中用API實現字體公用對話框例子

2024-07-21 02:20:47
字體:
來源:轉載
供稿:網友
private const lf_facesize = 32
private const cf_printerfonts = &h2
private const cf_screenfonts = &h1
private const cf_both = (cf_screenfonts or cf_printerfonts)
private const cf_effects = &h100&
private const cf_forcefontexist = &h10000
private const cf_inittologfontstruct = &h40&
private const cf_limitsize = &h2000&
private const regular_fonttype = &h400

'charset constants

private const ansi_charset = 0
private const arabic_charset = 178
private const baltic_charset = 186
private const chinesebig5_charset = 136
private const default_charset = 1
private const easteurope_charset = 238
private const gb2312_charset = 134
private const greek_charset = 161
private const hangeul_charset = 129
private const hebrew_charset = 177
private const johab_charset = 130
private const mac_charset = 77
private const oem_charset = 255
private const russian_charset = 204
private const shiftjis_charset = 128
private const symbol_charset = 2
private const thai_charset = 222
private const turkish_charset = 162

private type logfont


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 ' 10 * 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 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 = 10 ' minimum point size
cf.nsizemax = 72 ' 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 english 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




發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 保德县| 竹溪县| 蒲江县| 烟台市| 法库县| 丹凤县| 辽宁省| 都匀市| 公主岭市| 阿拉善盟| 沂源县| 定州市| 维西| 西畴县| 绍兴市| 庆阳市| 牟定县| 巴林左旗| 吉林省| 和林格尔县| 华安县| 志丹县| 长丰县| 泾阳县| 闽清县| 鄂托克旗| 永春县| 西充县| 奉新县| 鄂尔多斯市| 和田市| 正安县| 琼海市| 呼伦贝尔市| 稷山县| 虞城县| 高陵县| 景东| 改则县| 县级市| 格尔木市|