如何根据分辨率动态调整窗口大小?高分相送!!!急!!!

leopard29 2003-11-04 11:40:56
现有一段代码可以动态调整窗口的大小,但窗口里的数据窗口内的对象不能同步改变,导致部分字段不可显示,求救!!!急!急!急!在线等候。
...全文
169 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
damezc 2004-02-06
  • 打赏
  • 举报
回复
好什么如果碰上tab或userobject还不是不能调整。
tmxsl1214 2004-02-06
  • 打赏
  • 举报
回复
study
glucose 2004-02-04
  • 打赏
  • 举报
回复
谢谢leopard29(leopard) ,函数写得不错
leopard29 2003-11-25
  • 打赏
  • 举报
回复
environment env
integer ii_ScreenWidth,ii_ScreenHeight
double WRadio,HRadio,Radio
integer ii_WinBolderWidth,ii_WinBolderHeight
getenvironment(env)
ii_WinBolderWidth=w_zzll.width - w_zzll.WorkSpaceWidth()//取得窗体的边框宽度
ii_WinBolderHeight=w_zzll.height - w_zzll.WorkSpaceHeight()
ii_ScreenWidth=env.screenwidth
ii_ScreenHeight=env.screenheight
//compute the radio that need be resize

WRadio=ii_ScreenWidth/1024 //标准认为屏幕分辨率为800*600
HRadio=ii_ScreenHeight/768//计算出屏幕相对800*600分辨率的变化量
Radio=Min(WRadio,HRadio)
if Radio=1.0 then //if the screen is default 800*600
move(pos_x,pos_y)
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
move(pos_x,pos_y)
this.show()
return 0
langel 2003-11-06
  • 打赏
  • 举报
回复
接分
myf7961 2003-11-05
  • 打赏
  • 举报
回复
Integer iWindowWidth,iWindowHeight
Integer iWorkWidth,iWorkHeight
Integer iX,iY,iWidth,iHeight

//得到窗口的尺寸
iwindowwidth=this.width
iwindowheight=this.height
//messagebox("11111",string(iwindowwidth)+"+"+string(iwindowheight))
//得到工作区的尺寸
iworkwidth=this.workspacewidth()
iworkheight=this.workspaceheight()
//messagebox("22222",string(iworkwidth)+"+"+string(iworkheight))
if bFirstTime then //第一次修改窗口大小
//保存上次窗口尺寸
ilastwidth=iwindowwidth
ilastheight=iwindowheight
bFirstTime=false
return
else
//原始窗口不能调得过小,以避免控件重叠
if iwindowwidth<cb_close.x + cb_close.width or iwindowheight<dw_print.y+cb_close.y then
this.resize(iLastwidth,iLastheight)
return
end if
end if

//调整DATAWINDOW的大小
iwidth=iworkwidth - 2 * dw_print.x
iheight=iworkheight - dw_print.y - cb_close.y
dw_print.resize(iwidth,iheight)
//保存上次窗口尺寸
ilastwidth=iwidth
ilastheight=iheight

fossil2000 2003-11-05
  • 打赏
  • 举报
回复
OK,你好,搞定啦吧。
leopard29 2003-11-05
  • 打赏
  • 举报
回复
我自己已经搞定了。
mittee 2003-11-05
  • 打赏
  • 举报
回复
厉害厉害!把代码拿出来,学习学习。
iSunny001 2003-11-05
  • 打赏
  • 举报
回复
建议楼主把代码贴出来,有需要的可以从这里搜索,给大家提点方便,问此问题的不少。
您说呢,楼主。
jdsnhan 2003-11-05
  • 打赏
  • 举报
回复
恭喜楼主了。
dingzhaofeng 2003-11-05
  • 打赏
  • 举报
回复
over.
  • 打赏
  • 举报
回复
祝贺!!
接分!!!
workhand 2003-11-05
  • 打赏
  • 举报
回复
首先祝贺,再次希望楼主把代码思路说来给大家看看
klbt 2003-11-05
  • 打赏
  • 举报
回复
祝贺楼主自力更生!

604

社区成员

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

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