PB中轻松实现真正意义上的大字体工具栏

将以下代码保存为:uo_toolbarfont.sru文件,再在PB中导入,按照constructor()事件中的说明写上两行代码就可以轻松实现真正意义上的大字体工具栏.

请注意在PB11中的不同.

forward
global type uo_toolbarfont from nonvisualobject
end type
end forward

global type uo_toolbarfont from nonvisualobject
end type
global uo_toolbarfont uo_toolbarfont

type prototypes
function long FindWindowExA( long hParent, long hChildAfter, String lpszClass, String lpszWindow ) Library "user32.dll"
function long GetWindowLongA( long hWnd, integer index) Library "user32.dll"
function long FN_ToolBarSetFont(long unknown,string fontname,long fontsize,long unknown1,string str) library "pbvm90.dll"

end prototypes

type variables

end variables

forward prototypes
public function integer of_gettoolbarhandle (window aw_frame)
public subroutine of_settoolbarfont (window aw_frame, string as_fontname, integer ai_fontsize, string as_extent)
end prototypes

public function integer of_gettoolbarhandle (window aw_frame);long            ll_NULL, ll_hwndToolBar
string        ls_ClassName, ls_WindowName
Environment    lEnv

IF IsValid( aw_Frame ) AND (GetEnvironment(lEnv) = 1) THEN
        CHOOSE CASE lEnv.PBMajorRevision
            CASE 6
                ls_ClassName = "FNFIXEDBAR60"
            case 7
                ls_ClassName = "FNFIXEDBAR70"
            case 8
                ls_ClassName = "FNFIXEDBAR80"
            case 9
                ls_ClassName = "FNFIXEDBAR90"
            case 11
                ls_ClassName = "FNFIXEDBAR110"
            END CHOOSE
        SetNull(ls_WindowName)
        SetNull(ll_NULL)
        ll_hwndToolBar = FindWindowEXA( Handle(aw_Frame), ll_NULL, ls_ClassName, ls_WindowName )
END IF

RETURN ll_hwndToolBar
end function

public subroutine of_settoolbarfont (window aw_frame, string as_fontname, integer ai_fontsize, string as_extent);long ll_hwndToolBar,ll_unknown
ll_hwndToolBar = of_GetToolBarHandle( aw_frame)
if ll_hwndToolBar>0 then
    ll_unknown = GetWindowLongA(ll_hwndToolBar,0)
    //ll_unknown = GetWindowLongA(ll_hwndToolBar,-21)//PB11用
    FN_ToolBarSetFont(ll_unknown,as_fontname,ai_fontsize,0,as_extent)
end if

end subroutine

on uo_toolbarfont.create
call super::create
TriggerEvent( this, "constructor" )
end on

on uo_toolbarfont.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on

event constructor;/*
在MDI窗口的窗口变量声明中声明
//大字体工具栏
uo_toolbarfont iuo_toolbarfont
在open事件中调用:
iuo_toolbarfont.of_settoolbarfont (this,'宋体',-12,"1234567")
*/
end event

你可能感兴趣的:(String,function,Integer,工具,Constructor,subroutine)