国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

自適應屏幕分辨率的基類窗口(pb)

2024-07-21 02:10:25
字體:
來源:轉載
供稿:網友

做一個自適應屏幕分辨率的窗口,當成一個應用程序中所有窗體的基類。這樣整個程序可以很好的適應屏幕分辨率的改變。實現(xiàn)的原理很簡單,就是在窗口打開的時候去resize窗口和窗口中的控件大小,位置。參看下面的源代碼,可以很容易的看懂。

1。新建一個窗口。

為窗口寫一個函數(shù)f_resize()大部分工作就在這里。
無輸入參數(shù)
返回值為整形:

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

函數(shù)寫好以后,在窗體的open事件里調用該函數(shù)即可.

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 沂水县| 上饶市| 航空| 新余市| 平昌县| 永川市| 澄城县| 泗阳县| 固镇县| 大新县| 尚志市| 凤庆县| 墨竹工卡县| 乐业县| 中江县| 同德县| 始兴县| 哈密市| 秀山| 博白县| 宕昌县| 青海省| 天台县| 淮安市| 澎湖县| 丰城市| 梓潼县| 临桂县| 司法| 石河子市| 淮北市| 巴彦淖尔市| 梅河口市| 石柱| 淳化县| 淮滨县| 禹州市| 应城市| 台江县| 乐至县| 全州县|