PB自动适应屏幕

 

// PB Autosize 

environment env

integer ii_ScreenWidth,ii_ScreenHeight

double WRadio,HRadio,Radio

integer ii_WinBolderWidth,ii_WinBolderHeight

getenvironment(env)

ii_WinBolderWidth=this.width - this.WorkSpaceWidth()//取得窗体的边框宽度

ii_WinBolderHeight=this.height - this.WorkSpaceHeight()

ii_ScreenWidth=env.screenwidth

ii_ScreenHeight=env.screenheight

//compute the radio that need be resize

 

WRadio=ii_ScreenWidth/800 //标准认为屏幕分辨率为800*600

HRadio=ii_ScreenHeight/600//计算出屏幕相对800*600分辨率的变化量

Radio=Min(WRadio,HRadio)

if Radio=1.0 then //if the screen is default 800*600

return 0

end if

this.hide()

this.width=(this.width - ii_WinBolderWidth)*Radio + ii_WinBolderWidth

this.height=(this.height - ii_WinBolderHeight)*Radio + ii_WinBolderHeight

integer i

dragobject temp//用于取各种控件

 

for i=1 to upperbound(this.control)

temp=this.control[i]//调整大小,位置

temp.width=temp.width*Radio

temp.x=temp.x*Radio

temp.y=temp.y*Radio

temp.Height=temp.Height*Radio

choose case typeof(temp)

  case tab!

   tab mtab

   mtab=temp

   mtab.textsize =  mtab.textsize*Radio//设置字体

  case commandbutton!

   commandbutton cb

   cb = temp

   cb.textsize =  cb.textsize*Radio

 

  case singlelineedit!

   singlelineedit sle

   sle = temp

   sle.textsize=sle.textsize*Radio

  case editmask!

   editmask em

   em = temp

   em.textsize =  em.textsize*Radio

 

  case statictext!

   statictext st

   st = temp

   st.textsize = st.textsize*Radio

 

  case datawindow! // dataWindows get zoomed

   datawindow dw

   dw = temp

   dw.Object.DataWindow.zoom = string(int(Radio*100))//注意DATAWINDOW与其它控件的不同

 

  case picturebutton!

   picturebutton PB

   pb = temp

   pb.textsize =  pb.textsize*Radio

 

  case checkbox!

   checkbox cbx

   cbx = temp

   cbx.textsize =  cbx.textsize*Radio

 

  case dropdownlistbox!

   dropdownlistbox ddlb

   ddlb = temp

   ddlb.textsize =  ddlb.textsize*Radio

 

  case groupbox!

   groupbox gb

   gb = temp

   gb.textsize =  gb.textsize*Radio

 

  case listbox!

   listbox lb

   lb = temp

   lb.textsize  =  lb.textsize*Radio

 

  case multilineedit!

   multilineedit mle

   mle = temp

   mle.textsize = mle.textsize*Radio

 

  case radiobutton!

   radiobutton rb

   rb = temp

   rb.textsize =  rb.textsize*Radio

 

end choose

next

this.show()

return 0

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值