一段powerbuilder树控件的代码
发布:admin | 发布时间: 2010年1月11日这段代码是树控件的代码,是02年我给消防队开发程序时写的,写这段代码不知道费了多少脑细胞,看到不少坛友问树控件的代码怎么写,所以copy到这里,或许以后我也会用到。dw_2等数据窗口是我隐藏的,是用来提取数据用的,使用sql语句查询是一样的。
窗口的open事件:
long xt_newitem,xt_rootitem,ll_tvi,ll_tvparent,ll_count,ll_count1
integer rowcount
treeviewitem xt_tvitem,xt_zd,xt_danwei
int i,a,j
string name,ll_typename,leixing
tv_1.deleteitem(xt_rootitem)
xt_tvitem.label="中队名称"
xt_tvitem.pictureindex=1
xt_tvitem.selectedpictureindex=1
xt_rootitem=tv_1.insertitemlast(0,xt_tvitem)
leixing="交通工具类"
for i=1 to integer(dw_2.rowcount())
xt_zd.label=string(dw_2.getitemstring(i,"mingcheng"))
xt_zd.pictureindex=2
xt_zd.selectedpictureindex=2
tv_1.insertitemlast(1,xt_zd)//xt_zd为父项的名
next
for j=1 to integer(dw_2.rowcount())//中队个数
ll_typename=string(dw_2.getitemstring(j,"mingcheng"))//将中队名称付值给ll_typename
for a=1 to integer(dw_3.retrieve(ll_typename,leixing))
xt_danwei.label=string(dw_3.getitemstring(a,"dwmc"))
xt_danwei.pictureindex=3
xt_danwei.selectedpictureindex=3
tv_1.insertitemlast(j+1,xt_danwei)
next
next
树控件上的双击事件:
long ll_tvi,ll_tvparent
string ls_bianhao,ls_danweimc
TreeViewItem tvItem
String ls_label
tv_1.getItem(handle,tvItem)
ls_label = string(tvItem.label)
tab_1.tabpage_1.dw_4.retrieve(ls_label)
tab_1.tabpage_2.p_1.visible=false
tab_1.tabpage_3.p_2.visible=false
string txtname,named,bmpname
string defext = "BMP"
integer fh, ret,value
integer li_FileNum, loops, i,j,li_FileNum1,li_FileNum2,li_FileNum3
long flen, bytes_read, new_pos,flen_zong,flen_limt,flen_zhong
blob b, tot_b
B = Blob("")
tot_b=Blob("")
if tab_1.tabpage_1.dw_4.retrieve(ls_label)=1 /*and tab_1.tabpage_1.dw_4.getitemstring(1,"fangweitu")<>""*/ then
dw_1.retrieve(ls_label)
tab_1.tabpage_4.dw_5.retrieve(string(dw_1.getitemstring(1,"bianhao")),string(dw_1.getitemstring(1,"leixing")))
if string(tab_1.tabpage_1.dw_4.getitemstring(1,"xcfwt"))<>"" then
tab_1.tabpage_2.p_1.visible=true
flen = FileLength(string(tab_1.tabpage_1.dw_4.getitemstring(1,"xcfwt")))
//sle_1.text=string(tab_1.tabpage_1.dw_4.getitemstring(1,"fangweitu"))
//sle_1.text=string(flen)
txtname=string(tab_1.tabpage_1.dw_4.getitemstring(1,"xcfwt"))
li_FileNum = FileOpen(txtname,StreamMode!, Read!, LockRead!)
// Determine how many times to call FileRead
IF flen > 32765 THEN
IF Mod(flen, 32765) = 0 THEN
loops = flen/32765
ELSE
loops = (flen/32765) + 1
END IF
ELSE
loops = 1
END IF
// Read the file
new_pos = 1
FOR i = 1 to loops
bytes_read = FileRead(li_FileNum,b)
tot_b = tot_b + b
NEXT
tab_1.tabpage_2.p_1.SetPicture(tot_b)
FileClose(li_FileNum)
li_FileNum=0
B = Blob("")
tot_b=Blob("")
end if
if string(tab_1.tabpage_1.dw_4.getitemstring(1,"xczzbst"))<>"" then
tab_1.tabpage_3.p_2.visible=true
flen_zong = FileLength(string(tab_1.tabpage_1.dw_4.getitemstring(1,"xczzbst")))
//sle_1.text=string(flen_zong)
txtname=string(tab_1.tabpage_1.dw_4.getitemstring(1,"xczzbst"))
li_FileNum1 = FileOpen(txtname,StreamMode!, Read!, LockRead!)
// Determine how many times to call FileRead
IF flen_zong > 32765 THEN
IF Mod(flen_zong, 32765) = 0 THEN
loops = flen_zong/32765
ELSE
loops = (flen_zong/32765) + 1
END IF
ELSE
loops = 1
END IF
// Read the file
new_pos = 1
FOR i = 1 to loops
bytes_read = FileRead(li_FileNum1,b)
tot_b = tot_b + b
NEXT
tab_1.tabpage_3.p_2.SetPicture(tot_b)
FileClose(li_FileNum1)
B = Blob("")
tot_b=Blob("")
end if
else
end if
文章如转载,请注明转载自:http://www.5iadmin.com/post/9.html
- 相关文章:
发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。