当前位置: 代码迷 >> PB >> 下拉列表框中怎么显示系统全部字体
  详细解决方案

下拉列表框中怎么显示系统全部字体

热度:580   发布时间:2016-04-29 10:41:38.0
下拉列表框中如何显示系统全部字体?
请问兄弟们,下拉列表框中如何显示系统全部字体?

------解决方案--------------------
有控件吧?
要不用ole插入字体控件
------解决方案--------------------
保存为w_get_font.srw,然后导入pbl中

C/C++ code
$PBExportHeader$w_get_font.srwforwardglobal type w_get_font from windowend typetype cb_2 from commandbutton within w_get_fontend typetype cb_1 from commandbutton within w_get_fontend typetype ddplb_1 from dropdownpicturelistbox within w_get_fontend typeend forwardglobal type w_get_font from windowinteger width = 914integer height = 284boolean titlebar = truestring title = "字体选择"boolean controlmenu = truewindowtype windowtype = response!long backcolor = 67108864string icon = "AppIcon!"boolean center = truecb_2 cb_2cb_1 cb_1ddplb_1 ddplb_1end typeglobal w_get_font w_get_fontforward prototypespublic function long wf_get_font (ref string as_fontname[])end prototypespublic function long wf_get_font (ref string as_fontname[]);environment l_envif GetEnvironment ( l_env ) <> 1 then return 0Long ll_FontCountInteger li_EndPos, li_EndPos1, li_EndPos2, IIf l_env.OSType = WindowsNT! Then //NT系统      //枚举所有字体名称    RegistryValues( "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Fonts", as_FontName)Elseif l_env.OSType = Windows! then    //系统为Windows 9X        //枚举所有字体名称    RegistryValues( "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Fonts", as_FontName)End If//获取字体的总数目ll_FontCount = UpperBound(as_FontName)//去除字体名称中的类型表述For I = 1 To ll_FontCount    li_EndPos1 = Pos(as_FontName[I], "Plain:1.0", 1)    li_EndPos2 = Pos(as_FontName[I], "&", 1)    If li_EndPos1 = 0 And li_EndPos2 = 0 Then        li_EndPos = Pos(as_FontName[I], "(", 1)        as_FontName[I] = Mid(as_FontName[I], 1, li_EndPos - 2)    ElseIf li_EndPos1 <> 0 And li_EndPos2 = 0 Then        as_FontName[I] = Mid(as_FontName[I], 1, li_EndPos1 - 2)    ElseIf li_EndPos1 = 0 And li_EndPos2 <> 0 Then        as_FontName[I] = Mid(as_FontName[I], 1, li_EndPos2 - 2)    End IfNext//更改常用的字体名称为实际名称For I = 1 To ll_FontCount    If as_FontName[I] = "楷体" Then as_FontName[I] = "楷体_GB2312"    If as_FontName[I] = "仿宋体" Then as_FontName[I] = "仿宋_GB2312"Nextas_FontName[ll_FontCount] = "新宋体"//返回字体数目Return ll_FontCountend functionon w_get_font.createthis.cb_2=create cb_2this.cb_1=create cb_1this.ddplb_1=create ddplb_1this.Control[]={this.cb_2,&this.cb_1,&this.ddplb_1}end onon w_get_font.destroydestroy(this.cb_2)destroy(this.cb_1)destroy(this.ddplb_1)end onevent open;String ls_FontName[], ls_defLong ll_FontCount, Ils_def = message.stringparmif ls_def = '' then ls_def = '华文彩云'//获取字体列表ll_FontCount = wf_Get_Font(ls_FontName)//将字体列表添加到下拉列表框中For I = 1 To ll_FontCount    if ls_FontName[I] <> '' then ddplb_1.AddItem(ls_FontName[I], 1)Next//列表框的初始值为文本编辑框的字体类型ddplb_1.Text = ls_def//重画窗口//This.SetReDraw(True)end eventtype cb_2 from commandbutton within w_get_fontinteger x = 485integer y = 112integer width = 293integer height = 76integer taborder = 20integer textsize = -9integer weight = 400fontcharset fontcharset = gb2312charset!fontpitch fontpitch = variable!string facename = "宋体"string text = "取消(&C)"end typeevent clicked;closewithreturn(parent,'')end eventtype cb_1 from commandbutton within w_get_fontinteger x = 128integer y = 112integer width = 293integer height = 76integer taborder = 20integer textsize = -9integer weight = 400fontcharset fontcharset = gb2312charset!fontpitch fontpitch = variable!string facename = "宋体"string text = "确定(&O)"end typeevent clicked;closewithreturn(parent,ddplb_1.text)end eventtype ddplb_1 from dropdownpicturelistbox within w_get_fontinteger x = 5integer width = 901integer height = 620integer taborder = 10integer textsize = -9integer weight = 400fontcharset fontcharset = gb2312charset!fontpitch fontpitch = variable!string facename = "宋体"boolean hscrollbar = trueboolean vscrollbar = trueborderstyle borderstyle = stylelowered!string picturename[] = {"StaticText!","StaticHyperLink!"}long picturemaskcolor = 12632256end type
  相关解决方案