使用PB9开发,里面用到2个自定义对象。
//uv_header_btn.sru
$PBExportHeader$uv_header_btn.sru
forward
global type uv_header_btn from commandbutton
end type
end forward
global type uv_header_btn from commandbutton
integer width = 457
integer height = 128
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "none"
end type
global uv_header_btn uv_header_btn
type variables
private uv_outlook owner
boolean expanded
end variables
forward prototypes
public subroutine setowner (uv_outlook as_owner)
end prototypes
public subroutine setowner (uv_outlook as_owner);this.owner=as_owner
end subroutine
event clicked;this.owner.Dynamic Trigger Event ue_header_clicked(this)//,this.tag
//核心关键
//pbdesigner的第一种方法应改为parent.Dynamic TriggerEvent(is_clickedevent),或PostEvent.
end event
on uv_header_btn.create
end on
on uv_header_btn.destroy
end on
//###分割线#####################################
//uv_outlook
$PBExportHeader$uv_outlook.sru
forward
global type uv_outlook from userobject
end type
type dw_1 from datawindow within uv_outlook
end type
end forward
global type uv_outlook from userobject
integer width = 827
integer height = 1792
long backcolor = 16777215
string text = "none"
long tabtextcolor = 33554432
long picturemaskcolor = 536870912
event ue_header_clicked ( uv_header_btn btn )
dw_1 dw_1
end type
global uv_outlook uv_outlook
type variables
public window parentwindow
private uv_header_btn ColumnHeaders[]
private int ii_valid_height
private string is_ColumnNames[],is_DwDatas[]
end variables
forward prototypes
public function integer resize (integer w, integer h)
public subroutine init (window as_win)
private subroutine f_expand (uv_header_btn as_btn)
private function integer getvalidheight ()
public subroutine setdata (any columntexts, any dwdatas)
private subroutine f_make_btn ()
private subroutine create_dw (integer as_index)
end prototypes
event ue_header_clicked(uv_header_btn btn);//current_header=btn
f_expand(btn)
//messagebox("",btn.tag)
end event
public function integer resize (integer w, integer h);//
//cb_1.move(0,0)
//cb_1.width=this.width - 20
//cb_1.height=88
int i
for i=UpperBound(ColumnHeaders) to 2 step -1
ColumnHeaders[i].y=this.y+ this.height - ColumnHeaders[i].height*(UpperBound(ColumnHeaders)+1 - i) - 10
next
ii_valid_height=ColumnHeaders[2].y - (ColumnHeaders[1].y+ColumnHeaders[1].Height) - 10
//
return 0
end function
public subroutine init (window as_win);this.parentwindow=as_win
//resize(0,0)
end subroutine
private subroutine f_expand (uv_header_btn as_btn);//
int index,i
index=integer(as_btn.tag)
//if index=UpperBound(ColumnHeaders) then
//
//else
//
//end if
if as_btn.expanded then return;
for i=1 to UpperBound(ColumnHeaders)
ColumnHeaders[i].expanded=false
next
dw_1.visible=false
//if index=1 then
// for i=UpperBound(ColumnHeaders) to 2 step -1
// ColumnHeaders[i].y=this.y+ this.height - ColumnHeaders[i].height*(UpperBound(ColumnHeaders)+1 - i) - 10
// next
// return
//end if
//if index=UpperBound(ColumnHeaders) then
//
//end if
for i=UpperBound(ColumnHeaders) to (index+1) step -1
ColumnHeaders[i].y=this.y+ this.height - ColumnHeaders[i].height*(UpperBound(ColumnHeaders)+1 - i) - 10
next
for i=2 to index
ColumnHeaders[i].y=ColumnHeaders[i - 1].y+ColumnHeaders[i].height
next
//if index=1 then
//
//else
// for i=2 to index
// ColumnHeaders[i].y=ColumnHeaders[i - 1].y+ColumnHeaders[i].height
// next
//end if
ColumnHeaders[index].expanded=true
//messagebox("","down:"+string(ColumnHeaders[index].y+ColumnHeaders[index].height))
//messagebox("",string(ColumnHeaders[index].x))
//messagebox("",string(dw_1.x)+" "+string(dw_1.y))
create_dw(index)
dw_1.y=ColumnHeaders[index].y+ColumnHeaders[index].height - this.y
dw_1.visible=true
dw_1.BringToTop = TRUE
//dw_1.retrieve( )
end subroutine
private function integer getvalidheight ();
return ii_valid_height;
end function
public subroutine setdata (any columntexts, any dwdatas);
is_ColumnNames=ColumnTexts
is_DwDatas=DwDatas
f_make_btn()
end subroutine
private subroutine f_make_btn ();int i
for i=1 to UpperBound(is_ColumnNames)
ColumnHeaders[i]=create uv_header_btn
ColumnHeaders[i].height=88
ColumnHeaders[i].width=this.width - 20
ColumnHeaders[i].text="××功能"+string(i)
ColumnHeaders[i].textsize=-9;
ColumnHeaders[i].tag=string(i)
ColumnHeaders[i].visible=true
ColumnHeaders[i].BringToTop = TRUE
ColumnHeaders[i].setOwner(this)
//ColumnHeaders[i].expanded=(i=1)
ColumnHeaders[i].expanded=false
parentwindow.OpenUserObject(ColumnHeaders[i],'uv_header_btn',this.x+10,this.y+10)
next
for i=UpperBound(ColumnHeaders) to 2 step -1
ColumnHeaders[i].y=this.y+ this.height - ColumnHeaders[i].height*(UpperBound(ColumnHeaders)+1 - i) - 10
next
ii_valid_height=ColumnHeaders[2].y - (ColumnHeaders[1].y+ColumnHeaders[1].Height) - 10
dw_1.x=ColumnHeaders[1].x - this.x
dw_1.width=ColumnHeaders[1].width
dw_1.height=this.getValidheight( )
dw_1.visible=false
this.trigger event ue_header_clicked(ColumnHeaders[1])
//
end subroutine
private subroutine create_dw (integer as_index);//
string ls_str,ls_msg
int i,li_px,li_py,li_bgx,li_bgy,li_step,li_bgw,li_bgh
datastore ds
ds=create datastore
li_step=10
ls_str="release 9; " + &
"datawindow(units=0 timer_interval=0 color=1073741824 processing=0 HTMLDW=no print.printername=~"~" print.documentname=~"~" print.orientation = 0 print.margin.left = 110 print.margin.right = 110 print.margin.top = 96 print.margin.bottom = 96 print.paper.source = 0 print.paper.size = 0 print.canusedefaultprinter=yes print.prompt=no print.buttons=no print.preview.buttons=no print.cliptext=no print.overrideprintjob=no print.collate=yes hidegrayline=no ) " + &
"detail(height=268 color=~"536870912~" ) " + &
"table(column=(type=char(255) updatewhereclause=yes name=t_text dbname=~"t_text~" ) " + &
" column=(type=char(255) updatewhereclause=yes name=t_tag dbname=~"t_tag~" ) " + &
" column=(type=char(255) updatewhereclause=yes name=t_pic dbname=~"t_pic~" ) " + &
" column=(type=char(10) updatewhereclause=yes name=t_width dbname=~"t_width~" ) " + &
" column=(type=char(10) updatewhereclause=yes name=t_height dbname=~"t_height~" ) " + &
" ) " + &
"column(band=detail id=1 alignment=~"2~" tabsequence=32766 border=~"0~" color=~"33554432~" x=~"9~" y=~"172~" height=~"60~" width=~"297~" format=~"[general]~" html.valueishtml=~"0~" name=t_text visible=~"1~" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=no edit.imemode=0 font.face=~"Arial~" font.height=~"-9~" font.weight=~"400~" font.family=~"2~" font.pitch=~"2~" font.charset=~"0~" background.mode=~"2~" background.color=~"1073741824~" ) " + &
"column(band=detail id=1 alignment=~"2~" tabsequence=32766 border=~"0~" color=~"33554432~" x=~"421~" y=~"24~" height=~"60~" width=~"297~" format=~"[general]~" html.valueishtml=~"0~" name=t_tag visible=~"1~" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=no edit.imemode=0 font.face=~"Arial~" font.height=~"-9~" font.weight=~"400~" font.family=~"2~" font.pitch=~"2~" font.charset=~"0~" background.mode=~"2~" background.color=~"1073741824~" ) " + &
"column(band=detail id=1 alignment=~"2~" tabsequence=32766 border=~"0~" color=~"33554432~" x=~"421~" y=~"24~" height=~"60~" width=~"297~" format=~"[general]~" html.valueishtml=~"0~" name=t_pic visible=~"1~" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=no edit.imemode=0 font.face=~"Arial~" font.height=~"-9~" font.weight=~"400~" font.family=~"2~" font.pitch=~"2~" font.charset=~"0~" background.mode=~"2~" background.color=~"1073741824~" ) " + &
"column(band=detail id=1 alignment=~"2~" tabsequence=32766 border=~"0~" color=~"33554432~" x=~"421~" y=~"24~" height=~"60~" width=~"297~" format=~"[general]~" html.valueishtml=~"0~" name=t_width visible=~"1~" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=no edit.imemode=0 font.face=~"Arial~" font.height=~"-9~" font.weight=~"400~" font.family=~"2~" font.pitch=~"2~" font.charset=~"0~" background.mode=~"2~" background.color=~"1073741824~" ) " + &
"column(band=detail id=1 alignment=~"2~" tabsequence=32766 border=~"0~" color=~"33554432~" x=~"421~" y=~"24~" height=~"60~" width=~"297~" format=~"[general]~" html.valueishtml=~"0~" name=t_height visible=~"1~" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=no edit.imemode=0 font.face=~"Arial~" font.height=~"-9~" font.weight=~"400~" font.family=~"2~" font.pitch=~"2~" font.charset=~"0~" background.mode=~"2~" background.color=~"1073741824~" ) "
ds.create( ls_str, ls_msg)
//messagebox("",ls_msg)
ds.importstring(is_DwDatas[as_index])
//messagebox("",string(ds.rowcount()))
li_px=(this.width - integer(ds.getitemstring(1,"t_width")))/2
li_py=li_step
li_bgx=(this.width - integer(ds.getitemstring(1,"t_width")) - li_step*2)/2
li_bgy=0
li_bgw=integer(ds.getitemstring(1,"t_width"))+li_step*2
li_bgh=integer(ds.getitemstring(1,"t_height"))+li_step*2
ls_str="release 9; " + &
"datawindow(units=0 timer_interval=0 color=1073741824 processing=0 HTMLDW=no print.printername=~"~" print.documentname=~"~" print.orientation = 0 print.margin.left = 110 print.margin.right = 110 print.margin.top = 96 print.margin.bottom = 96 print.paper.source = 0 print.paper.size = 0 print.canusedefaultprinter=yes print.prompt=no print.buttons=no print.preview.buttons=no print.cliptext=no print.overrideprintjob=no print.collate=yes hidegrayline=no ) " + &
"detail(height="+string(li_bgy+li_bgh+100)+" color=~"536870912~" ) " + &
"table(column=(type=char(255) updatewhereclause=yes name=t_text dbname=~"t_text~" ) " + &
" column=(type=char(255) updatewhereclause=yes name=t_tag dbname=~"t_tag~" ) " + &
" column=(type=char(255) updatewhereclause=yes name=t_pic dbname=~"t_pic~" ) " + &
" column=(type=char(10) updatewhereclause=yes name=t_width dbname=~"t_width~" ) " + &
" column=(type=char(10) updatewhereclause=yes name=t_height dbname=~"t_height~" ) " + &
" )"
for i=1 to ds.rowcount()
ls_str+="text(band=detail alignment=~"0~" text=~"~" border=~"0~" color=~"33554432~" x=~""+string(li_bgx)+"~" y=~""+string(li_bgy)+"~" height=~""+string(li_bgh)+"~" width=~""+string(li_bgw)+"~" html.valueishtml=~"0~" name=t_bg_"+string(i)+" visible=~"0~" font.face=~"Arial~" font.height=~"-9~" font.weight=~"400~" font.family=~"2~" font.pitch=~"2~" font.charset=~"0~" background.mode=~"1~" background.color=~"15780518~" ) "
ls_str+="bitmap(band=detail filename=~""+ds.getitemstring(i,"t_pic")+"~" x=~""+string(li_px)+"~" y=~""+string(li_py)+"~" height=~""+ds.getitemstring(i,"t_height")+"~" width=~""+ds.getitemstring(i,"t_width")+"~" border=~"0~" name=p_"+string(i)+" pointer=~"HyperLink!~" visible=~"0~" ) "
next
ls_str+="column(band=detail id=1 alignment=~"2~" tabsequence=32766 border=~"0~" color=~"33554432~" x=~"0~" y=~""+string(li_bgy+li_bgh)+"~" height=~"60~" width=~""+string(this.width - 10)+"~" format=~"[general]~" html.valueishtml=~"0~" name=t_text visible=~"1~" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=no edit.imemode=0 font.face=~"Arial~" font.height=~"-9~" font.weight=~"400~" font.family=~"2~" font.pitch=~"2~" font.charset=~"0~" background.mode=~"2~" background.color=~"1073741824~" ) " + &
"column(band=detail id=1 alignment=~"2~" tabsequence=32766 border=~"0~" color=~"33554432~" x=~"421~" y=~"24~" height=~"60~" width=~"297~" format=~"[general]~" html.valueishtml=~"0~" name=t_tag visible=~"0~" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=no edit.imemode=0 font.face=~"Arial~" font.height=~"-9~" font.weight=~"400~" font.family=~"2~" font.pitch=~"2~" font.charset=~"0~" background.mode=~"2~" background.color=~"1073741824~" ) " + &
"column(band=detail id=1 alignment=~"2~" tabsequence=32766 border=~"0~" color=~"33554432~" x=~"421~" y=~"24~" height=~"60~" width=~"297~" format=~"[general]~" html.valueishtml=~"0~" name=t_pic visible=~"0~" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=no edit.imemode=0 font.face=~"Arial~" font.height=~"-9~" font.weight=~"400~" font.family=~"2~" font.pitch=~"2~" font.charset=~"0~" background.mode=~"2~" background.color=~"1073741824~" ) " + &
"column(band=detail id=1 alignment=~"2~" tabsequence=32766 border=~"0~" color=~"33554432~" x=~"421~" y=~"24~" height=~"60~" width=~"297~" format=~"[general]~" html.valueishtml=~"0~" name=t_width visible=~"0~" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=no edit.imemode=0 font.face=~"Arial~" font.height=~"-9~" font.weight=~"400~" font.family=~"2~" font.pitch=~"2~" font.charset=~"0~" background.mode=~"2~" background.color=~"1073741824~" ) " + &
"column(band=detail id=1 alignment=~"2~" tabsequence=32766 border=~"0~" color=~"33554432~" x=~"421~" y=~"24~" height=~"60~" width=~"297~" format=~"[general]~" html.valueishtml=~"0~" name=t_height visible=~"0~" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=no edit.imemode=0 font.face=~"Arial~" font.height=~"-9~" font.weight=~"400~" font.family=~"2~" font.pitch=~"2~" font.charset=~"0~" background.mode=~"2~" background.color=~"1073741824~" ) "
DESTROY ds
dw_1.create( ls_str,ls_msg)
dw_1.importstring(is_DwDatas[as_index])
for i=1 to dw_1.rowcount()
dw_1.Modify("p_"+string(i)+".Visible='1'")
next
//messagebox("",ls_msg)
//messagebox("",string(dw_1.rowcount()))
//mle_1.text=dw_1.Describe("DataWindow.Syntax")
end subroutine
on uv_outlook.create
this.dw_1=create dw_1
this.Control[]={this.dw_1}
end on
on uv_outlook.destroy
destroy(this.dw_1)
end on
event constructor;dw_1.settransobject(sqlca)
end event
type dw_1 from datawindow within uv_outlook
event ue_mousemove pbm_dwnmousemove
integer x = 64
integer y = 488
integer width = 686
integer height = 400
integer taborder = 10
boolean bringtotop = true
string title = "none"
boolean vscrollbar = true
boolean border = false
boolean livescroll = true
end type
event ue_mousemove;//
/*
if len(string(dwo.name))>0 then
//this.pointer
else
end if
HyperLink!
Cross!
15780518//蓝色 5
553648127//白色透明
*/
end event
event clicked;if row>0 and string(dwo.name)<>"datawindow" then
this.selectrow( 0, false)
this.selectrow( row, true)
messagebox("",string(dwo.name))
end if
end event
event retrieverow;//
//messagebox("","p_"+string(row)+".Visible='1'")
end event
//###分割线#####################################
将uv_outlook拖动套窗口(windwo)实例化变量名uo_1,一下是对uo_1操作:
uo_util tool
uo_1.init( this)
string ls_data[]
ls_data[1]="1功能1~t1~tc:\pic\cj.bmp~t140~t140~r~n1功能2~t2~tc:\pic\cx.bmp~t140~t140~r~n1功能3~t3~tc:\pic\qj.bmp~t140~t140~r~n"
ls_data[2]="2功能1~t1~tc:\pic\on.bmp~t140~t140~r~n2功能2~t2~tc:\pic\sp.bmp~t140~t140~r~n2功能3~t3~tc:\pic\tj.bmp~t140~t140~r~n"
//ls_data[3]="3功能1~t1~tpic~t140~t140~r~n3功能2~t2~tpic~t140~t140~r~n3功能3~t3~tpic~t140~t140~r~n"
uo_1.setdata( tool.split("××程序1,××程序2",","), ls_data)