在PB中,如何让程序自动适应不同的分辨率下运行!!!!

zx_maoer 2003-05-31 05:43:24
如在1024*768与860*640自动切换.各位请帮忙一下!!!
...全文
135 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
networld2002 2003-06-04
  • 打赏
  • 举报
回复
up
waterstony 2003-06-02
  • 打赏
  • 举报
回复
怎么样能自动改变分辨率

做一个自适应屏幕分辨率的窗口,当成一个应用程序中所有窗体的基类。这样整个程序可以很好的适应屏幕分辨率的改变。实现的原理很简单,就是在窗口打开的时候去RESIZE窗口和窗口中的控件大小,位置。参看下面的源代码,可以很容易的看懂。

1。新建一个窗口。

为窗口写一个函数f_resize()大部分工作就在这里。
无输入参数
返回值为整形:

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

函数写好以后,在窗体的OPEN事件里调用该函数即可.
cjh211 2003-06-02
  • 打赏
  • 举报
回复
用API,开始时将屏幕设为800*600(或其他分辨率),退出时恢复原来的分辨率。好象www.pdriver.com中有例程。
joss 2003-06-01
  • 打赏
  • 举报
回复
简单处理
每个窗口的resize都是动态完成的!
在resize中设置脚本!
根据屏幕尺寸来定义窗口体大小!这样就不怕分辨率来影响了!
hanhanprogramer 2003-05-31
  • 打赏
  • 举报
回复
可以在OPEN事件里面写一个读取当前屏幕大小并根据当前屏幕大小控制窗体大小的语句,在RESIZE事件里做一个控件数组,把各个控件一网打尽,根据窗体大小调整控件大小!!!
tchatcha 2003-05-31
  • 打赏
  • 举报
回复
做一个自适应屏幕分辨率的窗口,当成一个应用程序中所有窗体的基类。这样整个程序可以很好的适应屏幕分辨率的改变。实现的原理很简单,就是在窗口打开的时候去RESIZE窗口和窗口中的控件大小,位置。参看下面的源代码,可以很容易的看懂。

1。新建一个窗口。

为窗口写一个函数f_resize()大部分工作就在这里。
无输入参数
返回值为整形:

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

函数写好以后,在窗体的OPEN事件里调用该函数即可.


欣萱好米 2003-05-31
  • 打赏
  • 举报
回复
我遇到过这个问题!
见过相关的资料有方法,不过我不会用1
好象是用什么函数!
不过也要进行代码设置.
waterstony 2003-05-31
  • 打赏
  • 举报
回复
你搜搜吧,肯定有。“自动大小”,“resize”
zx_maoer 2003-05-31
  • 打赏
  • 举报
回复
如果每个控件都写脚本,那太麻烦了.有没有方便的方法???
homeness 2003-05-31
  • 打赏
  • 举报
回复
可以用api的函数获得屏幕的宽度和高度
fbc 2003-05-31
  • 打赏
  • 举报
回复
我只有一个苯的方法,就是所有的控件大小都用脚本写。
cb_width=200
cb_close.x=newwidth- cb_close.width
cb_close.height=120
cb_close.y=newheight - cb_close.height -20
你或者也可以把这些数字该为百分比,
其他的我就不知道用什么了。如果你知道请告诉我
csdnpaul 2003-05-31
  • 打赏
  • 举报
回复
我也遇到过同样的问题:
在1024*768下设计好的window,在860*640的模式下经常不能看到全部的内容。

604

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 控件与界面
社区管理员
  • 控件与界面社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧