祝愿大家身体健康!

 站点注册  找回密码
 站点注册

QQ登录

只需一步,快速开始

查看: 5639|回复: 2

[其它] 窗口上放一个分隔条,随着分隔条的左右移动,左右两边控件的宽度随着变化

[复制链接]

[其它] 窗口上放一个分隔条,随着分隔条的左右移动,左右两边控件的宽度随着变化

[复制链接]
ehxz

主题

0

回帖

57万

积分

管理员

积分
570013
贡献
在线时间
小时
2015-4-19 16:34:17 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?站点注册

×
主要是数据窗口的功能。
1、源代码:
  1. $PBExportHeader$lht_vo_splitter.sru
  2. $PBExportComments$分割条
  3. forward
  4. global type lht_vo_splitter from statictext
  5. end type
  6. end forward

  7. global type lht_vo_splitter from statictext
  8. integer width = 82
  9. integer height = 240
  10. integer textsize = -8
  11. fontcharset fontcharset = ansi!
  12. fontfamily fontfamily = roman!
  13. string facename = "Times New Roman"
  14. boolean focusrectangle = false
  15. event ue_lbuttondown pbm_lbuttondown
  16. event ue_lbuttonup pbm_lbuttonup
  17. event ue_win_mousemove pbm_mousemove
  18. event ue_drag ( long oldx,  long oldy )
  19. end type
  20. global lht_vo_splitter lht_vo_splitter

  21. type prototypes
  22. function ulong SetCapture(ulong hwnd)library "user32.dll"
  23. function ulong ReleaseCapture() library "user32.dll"
  24. end prototypes

  25. type variables
  26. long il_distance = 6
  27. boolean ib_live = true

  28. protected:
  29. userobject  iuo_1, iuo_2
  30. boolean ib_vertical = true

  31. boolean mousedown = false
  32. long oldxpos,oldypos

  33. end variables

  34. forward prototypes
  35. public subroutine of_setpointer ()
  36. public subroutine of_setleftright (readonly graphicobject ago_l, readonly graphicobject ago_r)
  37. public subroutine of_setupdown (readonly graphicobject ago_u, readonly graphicobject ago_d)
  38. public subroutine of_resize ()
  39. public subroutine of_resize (integer ai)
  40. public subroutine of_setleftright (readonly graphicobject ago_l, readonly graphicobject ago_r, integer ai)
  41. public subroutine of_setupdown (readonly graphicobject ago_u, readonly graphicobject ago_d, integer ai)
  42. end prototypes

  43. event ue_lbuttondown;ulong hnd
  44. mousedown = true
  45. oldxpos = unitstopixels( xpos, xunitstopixels! )
  46. oldypos = unitstopixels( ypos, yunitstopixels! )
  47. this.bringtotop = true
  48. this.border = false
  49. hnd = handle(this)
  50. SetCapture(hnd)
  51. end event

  52. event ue_lbuttonup;mousedown = false
  53. ReleaseCapture()
  54. if not ib_live then
  55. this.post event ue_drag( iuo_1.x, iuo_1.y )
  56. //iuo_2.setredraw( false )
  57. if ib_vertical then
  58. iuo_1.width = this.x - iuo_1.x
  59. iuo_2.width = iuo_2.x + iuo_2.width - this.x - this.width
  60. iuo_2.x = this.x + this.width
  61. else
  62. iuo_1.height = this.y - iuo_1.y
  63. iuo_2.height = iuo_2.y + iuo_2.height - this.y - this.height
  64. iuo_2.y = this.y + this.height
  65. end if
  66. iuo_1.triggerevent("ue_aftersize")
  67. //iuo_2.setredraw( true )
  68. end if
  69. end event

  70. event ue_win_mousemove;if not mousedown then
  71. return
  72. end if

  73. long nx,ny,tx,ty

  74. nx = unitstopixels( this.x, xunitstopixels! )
  75. ny = unitstopixels( this.y, yunitstopixels! )
  76. if ib_vertical then
  77. nx += unitstopixels( xpos, xunitstopixels! ) - oldxpos

  78. tx = unitstopixels( iuo_1.x, xunitstopixels! ) + il_distance
  79. if nx < tx then nx = tx
  80. tx = unitstopixels( iuo_2.x, xunitstopixels! ) + &
  81. unitstopixels( iuo_2.width, xunitstopixels! )- &
  82. unitstopixels( this.width, xunitstopixels! ) - il_distance
  83. if nx > tx then nx = tx
  84. else
  85. ny += unitstopixels( ypos, yunitstopixels! ) - oldypos

  86. ty = unitstopixels( iuo_1.y, yunitstopixels! ) + il_distance
  87. if ny < ty then ny = ty
  88. ty = unitstopixels( iuo_2.y, yunitstopixels! ) + &
  89. unitstopixels( iuo_2.height, yunitstopixels! ) - &
  90. unitstopixels( this.height, yunitstopixels! ) - il_distance
  91. if ny > ty then ny = ty
  92. end if

  93. tx = pixelstounits( nx - unitstopixels( this.x, xunitstopixels! ), xpixelstounits! )
  94. ty = pixelstounits( ny - unitstopixels( this.y, yunitstopixels! ), ypixelstounits! )
  95. if tx = 0 and ty = 0 then return
  96. if not ib_live then
  97. this.move( pixelstounits( nx, xpixelstounits! ), pixelstounits( ny, ypixelstounits! ) )
  98. this.setredraw(true)
  99. return
  100. end if
  101. if ib_vertical then
  102. iuo_1.width = iuo_1.width + tx
  103. iuo_2.setredraw( false )
  104. iuo_2.width = iuo_2.width - tx
  105. iuo_2.x = iuo_2.x + tx
  106. else
  107. iuo_1.height = iuo_1.height + ty
  108. iuo_2.setredraw( false )
  109. iuo_2.height = iuo_2.height - ty
  110. iuo_2.y = iuo_2.y + ty
  111. end if
  112. iuo_2.setredraw(true)
  113. tx = this.x
  114. ty = this.y
  115. this.move( pixelstounits( nx, xpixelstounits! ), pixelstounits( ny, ypixelstounits! ) )
  116. this.event ue_drag( tx, ty )
  117. end event

  118. public subroutine of_setpointer ();if isvalid( iuo_1 ) or isvalid( iuo_2 ) then
  119. if ib_vertical then
  120. this.pointer = "SizeWE!"
  121. else
  122. this.pointer = "SizeNS!"
  123. end if
  124. else
  125. this.pointer = "Arrow!"
  126. end if

  127. end subroutine

  128. public subroutine of_setleftright (readonly graphicobject ago_l, readonly graphicobject ago_r);of_setleftright(ago_l, ago_r,  2)
  129. end subroutine

  130. public subroutine of_setupdown (readonly graphicobject ago_u, readonly graphicobject ago_d);of_setupdown(ago_u, ago_d, 2)
  131. end subroutine

  132. public subroutine of_resize ();//默认为以右边或下方的控件为基准
  133. of_resize(2)
  134. end subroutine

  135. public subroutine of_resize (integer ai);//====================================================================
  136. // 过程(函数|Function): lht_vo_splitter::of_resize()
  137. //--------------------------------------------------------------------
  138. // 描述(Description):
  139. //--------------------------------------------------------------------
  140. // 变量(Arguments):
  141. //        value        integer        ai        1表示按左边或者上方的控件的设置分隔栏的高度或宽度
  142. //        1表示按右边或者下方的控件的设置分隔栏的高度或宽度
  143. //--------------------------------------------------------------------
  144. // 返回(Returns):  (none)
  145. //--------------------------------------------------------------------
  146. // 作者(Author):       
  147. //--------------------------------------------------------------------
  148. // 修改历史(Modify History):
  149. //       
  150. //--------------------------------------------------------------------
  151. //
  152. //====================================================================
  153. if not isvalid(iuo_1) or not isvalid(iuo_2) then return
  154. of_setpointer()
  155. if ib_vertical then
  156. if ai = 1 then
  157. this.y = iuo_1.y
  158. this.height = iuo_1.height
  159. else
  160. this.y = iuo_2.y
  161. this.height = iuo_2.height
  162. end if
  163. this.x = iuo_1.x + iuo_1.width
  164. long ll_w
  165. ll_w = width
  166. this.width = min(iuo_2.x - this.x, width)
  167. if width <= 0 then width = ll_w
  168. else
  169. if ai = 1 then
  170. this.x = iuo_1.x
  171. this.width = iuo_1.width
  172. else
  173. this.x = iuo_2.x
  174. this.width = iuo_2.width
  175. end if
  176. this.x = iuo_2.x
  177. this.width = iuo_2.width
  178. this.y = iuo_1.y + iuo_1.height
  179. long ll_h
  180. ll_h = height
  181. this.height = min(iuo_2.y - this.y        , height)
  182. if height <= 0 then height = ll_h
  183. end if
  184. end subroutine

  185. public subroutine of_setleftright (readonly graphicobject ago_l, readonly graphicobject ago_r, integer ai);iuo_1 = ago_l
  186. iuo_2 = ago_r
  187. ib_vertical = true
  188. of_resize( ai)
  189. end subroutine

  190. public subroutine of_setupdown (readonly graphicobject ago_u, readonly graphicobject ago_d, integer ai);
  191. //====================================================================
  192. // ai 位置基准
  193. //====================================================================
  194. iuo_1 = ago_u
  195. iuo_2 = ago_d
  196. ib_vertical = false
  197. of_resize(ai )
  198. end subroutine

  199. event constructor;this.enabled = true
  200. of_setpointer()

  201. end event

  202. on lht_vo_splitter.create
  203. end on

  204. on lht_vo_splitter.destroy
  205. end on
复制代码
将上面的代码存成lht_vo_splitter.sru 并用PB导入。
2、在PB界面的适合的地方,放入控件,并且时行调节
3、在constructor 事件编程:
  1. this.of_setleftright(dw_left, dw_right )
复制代码



PB9下测试成功!
共享共进共赢Sharing And Win-win Results
SYBASEBBS - 免责申明1、欢迎访问“SYBASEBBS.COM”,本文内容及相关资源来源于网络,版权归版权方所有!本站原创内容版权归本站所有,请勿转载!
2、本文内容仅代表作者观点,不代表本站立场,作者自负,本站资源仅供学习研究,请勿非法使用,否则后果自负!请下载后24小时内删除!
3、本文内容,包括但不限于源码、文字、图片等,仅供参考。本站不对其安全性,正确性等作出保证。但本站会尽量审核会员发表的内容。
4、如本帖侵犯到任何版权问题,请立即告知本站 ,本站将及时删除并致以最深的歉意!客服邮箱:admin@sybasebbs.com
ppszxc

主题

0

回帖

777

积分

高级会员

积分
777
贡献
在线时间
小时
2015-4-19 16:44:44 | 显示全部楼层
放个效果图来看看
共享共进共赢Sharing And Win-win Results
shun4132175

主题

0

回帖

619

积分

高级会员

积分
619
贡献
在线时间
小时
2023-11-9 10:11:40 | 显示全部楼层
我是来看效果的
共享共进共赢Sharing And Win-win Results
您需要登录后才可以回帖 登录 | 站点注册

本版积分规则

免责声明:
本站所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:Admin@SybaseBbs.com

QQ|Archiver|PowerBuilder(PB)BBS社区 ( 鲁ICP备2021027222号-1 )

GMT+8, 2024-4-20 19:42 , Processed in 0.056004 second(s), 10 queries , MemCached On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表