我想在PB的視窗里實作控制元件動態的改變大小,即在運行的時候可以動態的改變視窗里空件mle_1和dw_1的大小,聽別人在of_rgister(dw_1,1) of_rgister(dw_2,2) 但編譯的時候提示 unknow funcation name 'of_rgister' 到底要怎樣做呢?希望高手指點,本人感激不盡!!!!!并且希望詳細點,我以前用dellphi 和java 還是初次接觸pb,
QQ:634287660
uj5u.com熱心網友回復:
pfc中是通過pfc_n_cst_resize 類來管理控制元件動態大小或者位置縮放的 ,of_register(agru_list) 是注冊該控制元件為縮放控制元件,具體代碼到pfc_n_cst_resize 里面找。
題外話,"dellphi 和java 還是初次接觸pb" pb還沒有他們倆個好。
uj5u.com熱心網友回復:
在視窗里寫this.of_setresize(true)
this.inv_resize.of_register(dw_1, 0, 0, 100, 100)
即可
uj5u.com熱心網友回復:
給你個視窗代碼,直接繼承他就行了,支持嵌套tab控制元件===============================================
$PBExportHeader$w_size.srw
$PBExportComments$自動調整視窗大小的基類
forward
global type w_size from window
end type
end forward
global type w_size from window
integer width = 2533
integer height = 1408
boolean titlebar = true
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 15780518
string icon = "AppIcon!"
boolean center = true
event ue_position ( )
end type
global w_size w_size
type variables
boolean ib_autoresize = true
integer ii_orgwidth,ii_orgheight
dragobject ido_autosizecontrl[]
real irl_xbl[], irl_ybl[], irl_wbl[], irl_hbl[]
end variables
forward prototypes
public subroutine wf_init ()
end prototypes
event ue_position;integer i, j, k, li_dwcount = 0, li_ret, li_controls, js
Long ll_width, ll_height, ll
tab l_tab
userobject luo_control
ll_width=this.workspacewidth()
ll_height=this.workspaceheight()
js = 1
li_controls = upperbound( this.control[] )
FOR i = 1 TO li_controls
CHOOSE CASE this.control[i].typeof()
CASE line!, rectangle!, roundrectangle!, oval!
continue
CASE ELSE
ido_autosizecontrl[js] = this.control[i]
irl_xbl[js] = ido_autosizecontrl[js].x / ll_width
irl_ybl[js] = ido_autosizecontrl[js].y / ll_height
irl_wbl[js] = ido_autosizecontrl[js].width / ll_width
irl_hbl[js] = ido_autosizecontrl[js].height / ll_height
js ++
IF this.control[i].typeof() = tab! THEN
l_tab = control[i]
FOR j = 1 TO UpperBound(l_tab.control[])
FOR k = 1 TO UpperBound(l_tab.control[j].control[])
CHOOSE CASE l_tab.control[j].control[k].typeof()
CASE line!, rectangle!, roundrectangle!, oval!
continue
CASE ELSE
ido_autosizecontrl[js] = l_tab.control[j].control[k]
irl_xbl[js] = ido_autosizecontrl[js].x / ll_width
irl_ybl[js] = ido_autosizecontrl[js].y / ll_height
irl_wbl[js] = ido_autosizecontrl[js].width / ll_width
irl_hbl[js] = ido_autosizecontrl[js].height / ll_height
js ++
IF l_tab.control[j].control[k].typeof() = userobject! THEN
luo_control = l_tab.control[j].control[k]
FOR ll = 1 TO UpperBound(luo_control.control[])
CHOOSE CASE luo_control.control[ll].typeof()
CASE line!, rectangle!, roundrectangle!, oval!
continue
CASE ELSE
ido_autosizecontrl[js] = luo_control.control[ll]
irl_xbl[js] = ido_autosizecontrl[js].x / ll_width
irl_ybl[js] = ido_autosizecontrl[js].y / ll_height
irl_wbl[js] = ido_autosizecontrl[js].width / ll_width
irl_hbl[js] = ido_autosizecontrl[js].height / ll_height
js ++
END CHOOSE
NEXT
END IF
END CHOOSE
NEXT
NEXT
END IF
IF this.control[i].typeof() = userobject! THEN
luo_control = control[i]
FOR j = 1 TO UpperBound(luo_control.control[])
CHOOSE CASE luo_control.control[j].typeof()
CASE line!, rectangle!, roundrectangle!, oval!
continue
CASE ELSE
ido_autosizecontrl[js] = luo_control.control[j]
irl_xbl[js] = ido_autosizecontrl[js].x / ll_width
irl_ybl[js] = ido_autosizecontrl[js].y / ll_height
irl_wbl[js] = ido_autosizecontrl[js].width / ll_width
irl_hbl[js] = ido_autosizecontrl[js].height / ll_height
js ++
END CHOOSE
NEXT
END IF
END CHOOSE
NEXT
end event
public subroutine wf_init ();event ue_position()
end subroutine
event resize;Integer li_controls, i, j
String ls_xbl,ls_ybl,ls_wbl,ls_hbl
IF ib_autoresize THEN
//自動縮放
This.Setredraw(false)
li_controls=upperbound(ido_autosizecontrl[])
FOR j = 1 TO li_controls
ido_autosizecontrl[j].x = irl_xbl[j] * newwidth
ido_autosizecontrl[j].y = irl_ybl[j] * newheight
ido_autosizecontrl[j].width = irl_wbl[j] * newwidth
ido_autosizecontrl[j].height = irl_hbl[j] * newheight
NEXT
This.Setredraw(true)
END IF
end event
on w_size.create
end on
on w_size.destroy
end on
event open;event ue_position()
end event
===============================================
uj5u.com熱心網友回復:
如果你使用PFC開發就用2樓的方法如果不使用PFC可以參考3樓的設定自己調整控制元件視窗然后通過繼承的方式
uj5u.com熱心網友回復:
有沒有宣告pfc_n_cst_resize的物件?uj5u.com熱心網友回復:
//Declare Instance Variables
pfc_n_cst_resize uo_resize
//open事件
uo_resize = Create pfc_n_cst_resize
uo_resize.of_SetOrigSize(Width, Height)
uo_resize.of_register(dw_1, 'ScaleToRight&Bottom')
//還有其他縮放型別引數
// 'FixedToRight'
// 'FixedToBottom'
// 'FixedToRight&Bottom'
// 'Scale'
// 'ScaleToRight'
// 'ScaleToBottom'
// 'ScaleToRight&Bottom'
// 'FixedToRight&ScaleToBottom'
// 'FixedToBottom&ScaleToRight'
//resize事件
uo_resize.Trigger Event pfc_resize(1, newwidth, newheight)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/97938.html
標籤:控件與界面
下一篇:mapX在PB里的開發問題
