马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?站点注册
×
主要是数据窗口的功能。
1、源代码:
- $PBExportHeader$lht_vo_splitter.sru
- $PBExportComments$分割条
- forward
- global type lht_vo_splitter from statictext
- end type
- end forward
- global type lht_vo_splitter from statictext
- integer width = 82
- integer height = 240
- integer textsize = -8
- fontcharset fontcharset = ansi!
- fontfamily fontfamily = roman!
- string facename = "Times New Roman"
- boolean focusrectangle = false
- event ue_lbuttondown pbm_lbuttondown
- event ue_lbuttonup pbm_lbuttonup
- event ue_win_mousemove pbm_mousemove
- event ue_drag ( long oldx, long oldy )
- end type
- global lht_vo_splitter lht_vo_splitter
- type prototypes
- function ulong SetCapture(ulong hwnd)library "user32.dll"
- function ulong ReleaseCapture() library "user32.dll"
- end prototypes
- type variables
- long il_distance = 6
- boolean ib_live = true
- protected:
- userobject iuo_1, iuo_2
- boolean ib_vertical = true
- boolean mousedown = false
- long oldxpos,oldypos
- end variables
- forward prototypes
- public subroutine of_setpointer ()
- public subroutine of_setleftright (readonly graphicobject ago_l, readonly graphicobject ago_r)
- public subroutine of_setupdown (readonly graphicobject ago_u, readonly graphicobject ago_d)
- public subroutine of_resize ()
- public subroutine of_resize (integer ai)
- public subroutine of_setleftright (readonly graphicobject ago_l, readonly graphicobject ago_r, integer ai)
- public subroutine of_setupdown (readonly graphicobject ago_u, readonly graphicobject ago_d, integer ai)
- end prototypes
- event ue_lbuttondown;ulong hnd
- mousedown = true
- oldxpos = unitstopixels( xpos, xunitstopixels! )
- oldypos = unitstopixels( ypos, yunitstopixels! )
- this.bringtotop = true
- this.border = false
- hnd = handle(this)
- SetCapture(hnd)
- end event
- event ue_lbuttonup;mousedown = false
- ReleaseCapture()
- if not ib_live then
- this.post event ue_drag( iuo_1.x, iuo_1.y )
- //iuo_2.setredraw( false )
- if ib_vertical then
- iuo_1.width = this.x - iuo_1.x
- iuo_2.width = iuo_2.x + iuo_2.width - this.x - this.width
- iuo_2.x = this.x + this.width
- else
- iuo_1.height = this.y - iuo_1.y
- iuo_2.height = iuo_2.y + iuo_2.height - this.y - this.height
- iuo_2.y = this.y + this.height
- end if
- iuo_1.triggerevent("ue_aftersize")
- //iuo_2.setredraw( true )
- end if
- end event
- event ue_win_mousemove;if not mousedown then
- return
- end if
- long nx,ny,tx,ty
- nx = unitstopixels( this.x, xunitstopixels! )
- ny = unitstopixels( this.y, yunitstopixels! )
- if ib_vertical then
- nx += unitstopixels( xpos, xunitstopixels! ) - oldxpos
- tx = unitstopixels( iuo_1.x, xunitstopixels! ) + il_distance
- if nx < tx then nx = tx
- tx = unitstopixels( iuo_2.x, xunitstopixels! ) + &
- unitstopixels( iuo_2.width, xunitstopixels! )- &
- unitstopixels( this.width, xunitstopixels! ) - il_distance
- if nx > tx then nx = tx
- else
- ny += unitstopixels( ypos, yunitstopixels! ) - oldypos
- ty = unitstopixels( iuo_1.y, yunitstopixels! ) + il_distance
- if ny < ty then ny = ty
- ty = unitstopixels( iuo_2.y, yunitstopixels! ) + &
- unitstopixels( iuo_2.height, yunitstopixels! ) - &
- unitstopixels( this.height, yunitstopixels! ) - il_distance
- if ny > ty then ny = ty
- end if
- tx = pixelstounits( nx - unitstopixels( this.x, xunitstopixels! ), xpixelstounits! )
- ty = pixelstounits( ny - unitstopixels( this.y, yunitstopixels! ), ypixelstounits! )
- if tx = 0 and ty = 0 then return
- if not ib_live then
- this.move( pixelstounits( nx, xpixelstounits! ), pixelstounits( ny, ypixelstounits! ) )
- this.setredraw(true)
- return
- end if
- if ib_vertical then
- iuo_1.width = iuo_1.width + tx
- iuo_2.setredraw( false )
- iuo_2.width = iuo_2.width - tx
- iuo_2.x = iuo_2.x + tx
- else
- iuo_1.height = iuo_1.height + ty
- iuo_2.setredraw( false )
- iuo_2.height = iuo_2.height - ty
- iuo_2.y = iuo_2.y + ty
- end if
- iuo_2.setredraw(true)
- tx = this.x
- ty = this.y
- this.move( pixelstounits( nx, xpixelstounits! ), pixelstounits( ny, ypixelstounits! ) )
- this.event ue_drag( tx, ty )
- end event
- public subroutine of_setpointer ();if isvalid( iuo_1 ) or isvalid( iuo_2 ) then
- if ib_vertical then
- this.pointer = "SizeWE!"
- else
- this.pointer = "SizeNS!"
- end if
- else
- this.pointer = "Arrow!"
- end if
- end subroutine
- public subroutine of_setleftright (readonly graphicobject ago_l, readonly graphicobject ago_r);of_setleftright(ago_l, ago_r, 2)
- end subroutine
- public subroutine of_setupdown (readonly graphicobject ago_u, readonly graphicobject ago_d);of_setupdown(ago_u, ago_d, 2)
- end subroutine
- public subroutine of_resize ();//默认为以右边或下方的控件为基准
- of_resize(2)
- end subroutine
- public subroutine of_resize (integer ai);//====================================================================
- // 过程(函数|Function): lht_vo_splitter::of_resize()
- //--------------------------------------------------------------------
- // 描述(Description):
- //--------------------------------------------------------------------
- // 变量(Arguments):
- // value integer ai 1表示按左边或者上方的控件的设置分隔栏的高度或宽度
- // 1表示按右边或者下方的控件的设置分隔栏的高度或宽度
- //--------------------------------------------------------------------
- // 返回(Returns): (none)
- //--------------------------------------------------------------------
- // 作者(Author):
- //--------------------------------------------------------------------
- // 修改历史(Modify History):
- //
- //--------------------------------------------------------------------
- //
- //====================================================================
- if not isvalid(iuo_1) or not isvalid(iuo_2) then return
- of_setpointer()
- if ib_vertical then
- if ai = 1 then
- this.y = iuo_1.y
- this.height = iuo_1.height
- else
- this.y = iuo_2.y
- this.height = iuo_2.height
- end if
- this.x = iuo_1.x + iuo_1.width
- long ll_w
- ll_w = width
- this.width = min(iuo_2.x - this.x, width)
- if width <= 0 then width = ll_w
- else
- if ai = 1 then
- this.x = iuo_1.x
- this.width = iuo_1.width
- else
- this.x = iuo_2.x
- this.width = iuo_2.width
- end if
- this.x = iuo_2.x
- this.width = iuo_2.width
- this.y = iuo_1.y + iuo_1.height
- long ll_h
- ll_h = height
- this.height = min(iuo_2.y - this.y , height)
- if height <= 0 then height = ll_h
- end if
- end subroutine
- public subroutine of_setleftright (readonly graphicobject ago_l, readonly graphicobject ago_r, integer ai);iuo_1 = ago_l
- iuo_2 = ago_r
- ib_vertical = true
- of_resize( ai)
- end subroutine
- public subroutine of_setupdown (readonly graphicobject ago_u, readonly graphicobject ago_d, integer ai);
- //====================================================================
- // ai 位置基准
- //====================================================================
- iuo_1 = ago_u
- iuo_2 = ago_d
- ib_vertical = false
- of_resize(ai )
- end subroutine
- event constructor;this.enabled = true
- of_setpointer()
- end event
- on lht_vo_splitter.create
- end on
- on lht_vo_splitter.destroy
- end on
复制代码 将上面的代码存成lht_vo_splitter.sru 并用PB导入。
2、在PB界面的适合的地方,放入控件,并且时行调节
3、在constructor 事件编程:
- this.of_setleftright(dw_left, dw_right )
复制代码
PB9下测试成功!
|