posts - 14,  comments - 3,  trackbacks - 0
祖先窗口的设计: 

目的:让窗口能居中、窗口及其中所有控件均能自由伸缩,而位置关系不变。 

建祖先窗口名为:w_autosize 

  

declare instance variables 

integer                            ii_orgwidth,ii_orgheight
checkbox                         icbx_obj
radiobutton                      irb_obj
commandbutton               icb_obj
datawindow                    idw_obj
dropdownlistbox              iddlb_obj
dropdownpicturelistbox       iddplb_obj
editmask                           iem_obj
groupbox          igb_obj
hscrollbar         ihsb_obj
line           iln_obj
listbox          ilb_obj
listview           ilv_obj
multilineedit            imle_obj
picture         ip_obj
picturebutton                               ipb_obj
picturelistbox       iplb_obj
singlelineedit                               isle_obj
tab                                             it_obj
treeview         itv_obj
userobject        iuo_obj
vscrollbar        ivsb_obj
graph                                         igr_obj
olecontrol                                   iole_obj
richtextedit        irte_obj
statictext                                     ist_obj
statichyperlink                             ishl_obj
integer v_li=1
integer v_lj=1
private:
struct_consize s_consize 

  

  

函数:f_center()  
return  integer 

int li_screenheight,li_screenwidth,li_rc,li_x=1,li_y=1
environment lenv_obj 

if isnull(this) or not isvalid(this) then return -1
if GetEnvironment(lenv_obj)=-1 then return -1
//屏幕高度与屏幕宽度(转换成PB格式)
li_screenheight
=PixelsToUnits(lenv_obj.screenheight,ypixelstounits!)
li_screenwidth
=PixelsToUnits(lenv_obj.screenwidth,xpixelstounits!) 

if not (li_screenheight>0or not (li_screenwidth>0then return -1 

if li_screenwidth>this.width then
 li_x
=(li_screenwidth/2- (this.width/2)
end if 

if li_screenheight>this.height then
 li_y
=(li_screenwidth/2)-(this.height/2)
end if 

li_rc
=this.move(li_x,li_y) 

if li_rc<>1 then return -1 

return 1 

函数:uf_position(windowobject  v_winobj,
long ll_width,long ll_height)  return integer 

dragobject dragcontrol
line line_contr
oval oval_contr
rectangle rect_contr
roundrectangle roun_contr
tab l_tab
userobject luo_control
choose 
case v_winobj.typeof()
 
case commandbutton! , picturebutton! , checkbox! , radiobutton! , &
  statictext! , statichyperlink! , picture! , 
&
  picturehyperlink! , groupbox! , singlelineedit! , editmask! , 
&
  multilineedit! , richtextedit! , hscrollbar! , vscrollbar! , 
&
  htrackbar! , vtrackbar! , hprogressbar! , vprogressbar! ,
&
  dropdownlistbox! , dropdownpicturelistbox! , listbox! ,
&
  picturelistbox! , listview! , treeview! , datawindow! ,
&
  graph! , olecontrol! 
  
  dragcontrol
=v_winobj
  s_consize.s_conx
[v_li]=dragcontrol.x/ll_width
  s_consize.s_cony
[v_li]=dragcontrol.y/ll_height
  s_consize.s_conw
[v_li]=dragcontrol.width/ll_width
  s_consize.s_conh
[v_li]=dragcontrol.height/ll_height
  v_li
=v_li+1
  
 
case line!
  line_contr
=v_winobj
  s_consize.s_conx
[v_li]=line_contr.beginx/ll_width
  s_consize.s_cony
[v_li]=line_contr.beginy/ll_height
  s_consize.s_conw
[v_li]=line_contr.endx/ll_width
  s_consize.s_conh
[v_li]=line_contr.endy/ll_height
  v_li
=v_li+1
 
case oval!
  oval_contr
=v_winobj
  s_consize.s_conx
[v_li]=oval_contr.x/ll_width
  s_consize.s_cony
[v_li]=oval_contr.y/ll_height
  s_consize.s_conw
[v_li]=oval_contr.width/ll_width
  s_consize.s_conh
[v_li]=oval_contr.height/ll_height
  v_li
=v_li+1
 
case rectangle!
  rect_contr
=v_winobj
  s_consize.s_conx
[v_li]=rect_contr.x/ll_width
  s_consize.s_cony
[v_li]=rect_contr.y/ll_height
  s_consize.s_conw
[v_li]=rect_contr.width/ll_width
  s_consize.s_conh
[v_li]=rect_contr.height/ll_height
  v_li
=v_li+1
 
case roundrectangle!
  roun_contr
=v_winobj
  s_consize.s_conx
[v_li]=roun_contr.x/ll_width
  s_consize.s_cony
[v_li]=roun_contr.y/ll_height
  s_consize.s_conw
[v_li]=roun_contr.width/ll_width
  s_consize.s_conh
[v_li]=roun_contr.height/ll_height
  v_li
=v_li+1
 
case tab!
  l_tab
=v_winobj
  s_consize.s_conx
[v_li]=l_tab.x/ll_width
  s_consize.s_cony
[v_li]=l_tab.y/ll_height
  s_consize.s_conw
[v_li]=l_tab.width/ll_width
  s_consize.s_conh
[v_li]=l_tab.height/ll_height
  v_li
=v_li+1
  
  
integer li_ti1 , li_ti2
  
for li_ti1 = 1  to  upperbound(l_tab.control[])
   
for li_ti2 = 1 to upperbound( l_tab.control[li_ti1].control[] )
    uf_position(l_tab.control
[li_ti1].control[li_ti2],ll_width,ll_height)
   
next
  
next
 
case userobject!
  luo_control
=v_winobj
  s_consize.s_conx
[v_li]=luo_control.x/ll_width
  s_consize.s_cony
[v_li]=luo_control.y/ll_height
  s_consize.s_conw
[v_li]=luo_control.width/ll_width
  s_consize.s_conh
[v_li]=luo_control.height/ll_height
  v_li
=v_li+1
  
integer li_uconnum,li_ui
  li_uconnum
=upperbound(luo_control.control[])
  
for li_ui=1 to li_uconnum
   uf_position(luo_control.control
[li_ui],ll_width,ll_height)
  
next
end choose
return 0 

  

函数:uf_resize(windowobject  v_winobj,
long ll_width,long ll_height)  return integer 

dragobject dragcontrol
line line_contr
oval oval_contr
rectangle rect_contr
roundrectangle roun_contr
tab l_tab
userobject luo_control
choose 
case v_winobj.typeof()
 
case commandbutton! , picturebutton! , checkbox! , radiobutton! , &
  statictext! , statichyperlink! , picture! , 
&
  picturehyperlink! , groupbox! , singlelineedit! , editmask! , 
&
  multilineedit! , richtextedit! , hscrollbar! , vscrollbar! , 
&
  htrackbar! , vtrackbar! , hprogressbar! , vprogressbar! ,
&
  dropdownlistbox! , dropdownpicturelistbox! , listbox! ,
&
  picturelistbox! , listview! , treeview! , datawindow! ,
&
  graph! , olecontrol! 
  
  dragcontrol
=v_winobj
  dragcontrol.move(s_consize.s_conx
[v_lj]*ll_width,s_consize.s_cony[v_lj]*ll_height)
  dragcontrol.resize(s_consize.s_conw
[v_lj]*ll_width,s_consize.s_conh[v_lj]*ll_height)
  v_lj
=v_lj+1
  
 
case line!
  line_contr
=v_winobj
  line_contr.beginx 
= s_consize.s_conx[v_lj]*ll_width
  line_contr.beginy 
= s_consize.s_cony[v_lj]*ll_height
  line_contr.endx 
= s_consize.s_conw[v_lj]*ll_width
  line_contr.endy 
= s_consize.s_conh[v_lj]*ll_height
  v_lj
=v_lj+1
  
 
case oval!
  oval_contr
=v_winobj
  oval_contr.x 
= s_consize.s_conx[v_lj]*ll_width
  oval_contr.y 
= s_consize.s_cony[v_lj]*ll_height
  oval_contr.width 
= s_consize.s_conw[v_lj]*ll_width
  oval_contr.height 
= s_consize.s_conh[v_lj]*ll_height
  v_lj
=v_lj+1
  
 
case rectangle!
  rect_contr
=v_winobj
  rect_contr.x 
= s_consize.s_conx[v_lj]*ll_width
  rect_contr.y 
= s_consize.s_cony[v_lj]*ll_height
  rect_contr.width 
= s_consize.s_conw[v_lj]*ll_width
  rect_contr.height 
= s_consize.s_conh[v_lj]*ll_height
  v_lj
=v_lj+1
  
 
case roundrectangle!
  roun_contr
=v_winobj
  roun_contr.x 
= s_consize.s_conx[v_lj]*ll_width
  roun_contr.y 
= s_consize.s_cony[v_lj]*ll_height
  roun_contr.width
=s_consize.s_conw[v_lj]*ll_width
  roun_contr.height 
= s_consize.s_conh[v_lj]*ll_height
  v_lj
=v_lj+1
  
 
case tab!
  l_tab
=v_winobj
  l_tab.x 
= s_consize.s_conx[v_lj]*ll_width
  l_tab.y 
= s_consize.s_cony[v_lj]*ll_height
  l_tab.width 
= s_consize.s_conw[v_lj]*ll_width
  l_tab.height 
= s_consize.s_conh[v_lj]*ll_height
  v_lj
=v_lj+1
  
integer li_ti1 , li_ti2
  
for li_ti1 = 1  to  upperbound(l_tab.control[])
   
for li_ti2 = 1 to upperbound( l_tab.control[li_ti1].control[] )
    uf_resize(l_tab.control
[li_ti1].control[li_ti2],ll_width,ll_height)
   
next
  
next
  
 
case userobject!
  luo_control
=v_winobj
  luo_control.x 
= s_consize.s_conx[v_lj]*ll_width
  luo_control.y 
= s_consize.s_cony[v_lj]*ll_height
  luo_control.width 
= s_consize.s_conw[v_lj]*ll_width
  luo_control.height 
= s_consize.s_conh[v_lj]*ll_height
  v_lj
=v_lj+1
  
integer li_uconnum,li_ui
  li_uconnum
=upperbound(luo_control.control[])
  
for li_ui=1 to li_uconnum
   uf_resize(luo_control.control
[li_ui],ll_width,ll_height)
  
next
end choose
return 0 

w_autosize open事件: 

long ll_width,ll_height
integer li_i
f_center( )
ll_width 
= this.workspacewidth( )
ll_height 
= this.workspaceheight( )
for li_i=1 to upperbound(this.control[])
 uf_position(this.control
[li_i],ll_width,ll_height)
next 

  

w_autosize resize事件: 

integer li_i
this.setredraw(false)
for li_i=1 to upperbound(this.control[])
 uf_resize(this.control
[li_i],newwidth,newheight)
next
v_lj
=1 

this.setredraw(true) 
posted on 2007-09-17 17:43 wlj768 阅读(343) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。
<2007年9月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

常用链接

留言簿(1)

随笔分类(11)

随笔档案(14)

文章分类(2)

1

搜索

  •  

最新评论

阅读排行榜

评论排行榜