|
本例中共有四个控件,一个窗口控件dw_1和三个按扭cb_1,cb_2,cb_3。
在窗口定义实例变量: Boolean bFirstTime //是否第一次打开窗口 Integer iOrigWidth,iOrigHeight //窗口原始尺寸 Integer iButtongap //按扭之间的距离 Integer iButton_Bottom,iButton_left,iButton_Dw //
在窗口OPEN事件中: bFirstTime=true
在窗口RESIZE事件中: Integer iWindowWidth,iWindowHeight Integer iWorkWidth,iWorkHeight Integer iX,iY,iWidth,iHeight
//得到窗口的尺寸 iwindowwidth=this.width iwindowheight=this.height
//得到工作区的尺寸 iworkwidth=this.workspacewidth() iworkheight=this.workspaceheight()
if bFirstTime then //第一次修改窗口大小 //保存原始尺寸 iorigwidth=iwindowwidth iorigheight=iwindowheight ibuttongap=cb_2.x - (cb_1.x + cb_1.width) ibutton_bottom=iworkheight - (cb_1.y + cb_1.height) ibutton_left=cb_1.x ibutton_dw=cb_1.y - dw_1.height bFirstTime=false return else //原始窗口不能调得过小,以避免控件重叠 if iwindowwidth$#@60;cb_3.x + cb_3.width + ibutton_left or iwindowheight$#@60;cb_1.height + ibutton_dw +ibutton_bottom + dw_1.y then this.resize(iorigwidth,iorigheight) return end if end if
//调整按钮位置 ix=ibutton_left iy=iworkheight - (ibutton_bottom + cb_1.height) cb_1.move(ix,iy)
ix=ix + cb_1.width + ibuttongap cb_2.move(ix,iy)
ix=ix + cb_2.width + ibuttongap cb_3.move(ix,iy)
//调整DW控件大小 iwidth=iworkwidth - 2 * dw_1.x iheight=cb_1.y -dw_1.y - ibutton_dw dw_1.resize(iwidth,iheight)
|