我有一個自定義控制元件
在程式中用OpenUserObject加載了自定義控制元件
if NOT isvalid(uo_wlzb) then
uo_wlzb =create uo_manager_wlzb
this.OpenUserObject(uo_wlzb, "uo_wlzb ", uo_bl.x, uo_bl.y)
SetParent(Handle(uo_wlzb), Handle(THIS))
uo_wlzb.Width = uo_bl.width
uo_wlzb.Height = uo_bl.height
uo_wlzb.wf_resize(uo_wlzb.width,uo_wlzb.height)
end if
uo_wlzb.visible=true
在一個BUTTON中用closeuserobject卸載
if isvalid(uo_wlzb) then
destroy uo_wlzb
parent.closeuserobject(uo_wlzb)
END IF
但卸載不干凈,界面還存在,只是點擊該界面程式會自動退出,如果再重新加載程式也會退出
請問高手門,自定義控制元件的加載和卸載如何控制呀,不能用托入控制的方式,要用程式控制。
有請了!
uj5u.com熱心網友回復:
if isvalid(uo_wlzb) then
//destroy uo_wlzb 這一句去掉
parent.closeuserobject(uo_wlzb)
END IF
uj5u.com熱心網友回復:
呵呵,去掉destroy uo_wlzb 沒有用啊,我已經試了。uj5u.com熱心網友回復:
uo_wlzb是怎么定義的將以下兩個物件匯入(新建的)pbl試試
uo_manager_wlzb.sru
$PBExportHeader$uo_manager_wlzb.sru
forward
global type uo_manager_wlzb from userobject
end type
type cb_1 from commandbutton within uo_manager_wlzb
end type
end forward
global type uo_manager_wlzb from userobject
integer width = 571
integer height = 600
boolean border = true
long backcolor = 67108864
string text = "none"
long tabtextcolor = 33554432
long picturemaskcolor = 536870912
cb_1 cb_1
end type
global uo_manager_wlzb uo_manager_wlzb
on uo_manager_wlzb.create
this.cb_1=create cb_1
this.Control[]={this.cb_1}
end on
on uo_manager_wlzb.destroy
destroy(this.cb_1)
end on
type cb_1 from commandbutton within uo_manager_wlzb
integer x = 87
integer y = 128
integer width = 457
integer height = 128
integer taborder = 10
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "none"
end type
w_main1.srw
$PBExportHeader$w_main1.srw
forward
global type w_main1 from window
end type
type cb_3 from commandbutton within w_main1
end type
type st_2 from statictext within w_main1
end type
type ddplb_1 from dropdownpicturelistbox within w_main1
end type
end forward
global type w_main1 from window
integer width = 2126
integer height = 1264
boolean titlebar = true
string title = "服務實體"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
cb_3 cb_3
st_2 st_2
ddplb_1 ddplb_1
end type
global w_main1 w_main1
type prototypes
Function Long SetParent(Long childwin, Long parentwin) Library "user32.dll"
end prototypes
type variables
uo_manager_wlzb uo_wlzb
end variables
on w_main1.create
this.cb_3=create cb_3
this.st_2=create st_2
this.ddplb_1=create ddplb_1
this.Control[]={this.cb_3,&
this.st_2,&
this.ddplb_1}
end on
on w_main1.destroy
destroy(this.cb_3)
destroy(this.st_2)
destroy(this.ddplb_1)
end on
event open;
if NOT isvalid(uo_wlzb) then
uo_wlzb =create uo_manager_wlzb
this.OpenUserObject(uo_wlzb, "uo_wlzb", 0, 0)
SetParent(Handle(uo_wlzb), Handle(THIS))
uo_wlzb.Width = 1233
uo_wlzb.Height = 333
end if
uo_wlzb.visible=true
end event
type cb_3 from commandbutton within w_main1
integer x = 1326
integer y = 664
integer width = 457
integer height = 128
integer taborder = 30
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "none"
end type
event clicked;if isvalid(uo_wlzb) then
//destroy uo_wlzb
parent.closeuserobject(uo_wlzb)
END IF
end event
type st_2 from statictext within w_main1
integer x = 114
integer y = 1308
integer width = 393
integer height = 60
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
long backcolor = 67108864
string text = ""
boolean focusrectangle = false
end type
type ddplb_1 from dropdownpicturelistbox within w_main1
integer x = 850
integer y = 1276
integer width = 750
integer height = 376
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
boolean enabled = false
boolean sorted = false
string item[] = {"已停止","正在啟動","正在停止","正在運行","正在繼續","正在暫停","已暫停"}
borderstyle borderstyle = stylelowered!
integer itempictureindex[] = {1,2,3,4,5,6,7}
string picturename[] = {"DBDisconnect!","Start5!","StopDebugging!","DBConnect!","Continue!","Debug!","DeclareProcedure!"}
long picturemaskcolor = 536870912
end type
uj5u.com熱心網友回復:
樓上正解!樓主,你OpenUserObject的This跟你Button的Parent是不是對應的?
uj5u.com熱心網友回復:
建議樓主先簡化自己的程式流程來定位自己程式產生錯誤的位置。1. 首先可以肯定的是動態創建和銷毀表單中的自定義控制元件,只需要使用OpenUserObject和CloseUserObject即可。樓主可以將其他陳述句全部注釋,只保留這兩行代碼來測驗。
2. 其次,你的OpenUserObject代碼需要改為this.OpenUserObject(uo_wlzb, "uo_uo_manager_wlzb", uo_bl.x, uo_bl.y)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/75006.html
標籤:控件與界面
