如何让窗体随分辨率改变大小

20140 2003-05-16 06:25:10
我在800*600环境下做了一个占据整个屏幕的窗体,但是拿到1024*768分辨率时,窗体只占据了靠近左上角的一部分,很难看。如何能让窗体在不同分辨率下,都可以占据整个窗体呢?
请各位高手指教!!
...全文
61 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
AntiDragon 2003-05-19
  • 打赏
  • 举报
回复
me.move 0,0
me.height=screen.height
me.width=screen.width
label1.move 0,0
label1.height=me.height
label1.width=me.height
Daniel0318 2003-05-18
  • 打赏
  • 举报
回复
下面是一个模块
在form_load中调用函数ResizeInit
在form_resize中调用函数ResizeForm

'模块内容开始
public FormOldWidth as long
public FormOldHeight as long

public Sub ResizeInit(FormName as form) '记录窗体及各控件原始位置及尺寸
Dim Obj As Control

FormOldWidth = FormName.ScaleWidth
FormOldHeight = FormName.ScaleHeight

On Error Resume Next
For Each Obj In FormName
Obj.Tag = Obj.Left & " " & Obj.Top & " " & Obj.Width & " " & Obj.Height & " "
Next Obj
End Sub

public Sub ResizeForm(FormName as form) '当窗体大小发生变化时,各控件尺寸及位置作相应变化
Dim Pos '控件原先尺寸、位置
Dim I As Long '计数器
Dim Obj As Control '遍历窗体内控件
Dim ScaleX As Double, ScaleY As Double '缩放比例

ScaleX = Me.ScaleWidth / FormOldWidth

ScaleY = Me.ScaleHeight / FormOldHeight

On Error Resume Next

For Each Obj In Me
Pos = Split(Obj.Tag, " ", , vbTextCompare)
Obj.Move Pos(0) * ScaleX, Pos(1) * ScaleY, Pos(2) * ScaleX, Pos(3) * ScaleY
Next Obj
End Sub
20140 2003-05-18
  • 打赏
  • 举报
回复
我使用下面的语句
WELCOME.Height = Screen.Height
WELCOME.Width = Screen.Width
使窗体可以随分辨率改变大小,但是窗体上的控件还是在原来的位置,怎样能使控件也随窗体大小
改变位置??
lilaclone 2003-05-17
  • 打赏
  • 举报
回复
得到当前屏幕的分辨率:

ResWidth = Screen.Width Screen.TwipsPerPixelX

ResHeight = Screen.Height Screen.TwipsPerPixelY

ScreenRes = ResWidth & "x" & ResHeight

ResWidth和ResHeight分别表示屏幕的宽和高,比如这样的结果:

800x600
DylanChi 2003-05-16
  • 打赏
  • 举报
回复
宽和高取Screen的宽和高,即screen.height,screen.width

1,451

社区成员

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

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