VB中修改屏幕分辨率的问题 15
在VB中做了一个程序,是在分辨率为1280*1024的情况下,当把分辨率调高或者调低之后,怎么才能使窗体的控件全都能显示完整。如果是用代码强制改变分辨率的话,而显卡又不能...
在VB中做了一个程序,是在分辨率为1280*1024的情况下,当把分辨率调高或者调低之后,怎么才能使窗体的控件全都能显示完整。如果是用代码强制改变分辨率的话,而显卡又不能支持这个分辨率,这时应该怎么办?求各位解答一下
展开
1个回答
展开全部
Private Type ControlPlaces
Contrl As Control
Left As Single
Top As Single
Width As Single
Height As Single
End Type
Dim CtrlPos() As ControlPlaces
Private Sub Form_Load()
ReloadPos
End Sub
Sub ReloadPos()
ReDim CtrlPos(Me.Controls.Count)
Dim Ctrl As Control
Dim Num As Long
For Each Ctrl In Me.Controls
Set CtrlPos(Num).Contrl = Ctrl
CtrlPos(Num).Left = Ctrl.Left
CtrlPos(Num).Top = Ctrl.Top
CtrlPos(Num).Width = Ctrl.Width
CtrlPos(Num).Height = Ctrl.Height
Num = Num + 1
Next
CtrlPos(UBound(CtrlPos)).Left = Me.Left
CtrlPos(UBound(CtrlPos)).Top = Me.Top
CtrlPos(UBound(CtrlPos)).Width = Me.Width
CtrlPos(UBound(CtrlPos)).Height = Me.Height
End Sub
Private Sub Form_Resize()
WChng = Me.Width / CtrlPos(UBound(CtrlPos)).Width
HChng = Me.Height / CtrlPos(UBound(CtrlPos)).Height
For x = 0 To UBound(CtrlPos) - 1
CtrlPos(x).Contrl.Left = CtrlPos(x).Left * WChng
CtrlPos(x).Contrl.Top = CtrlPos(x).Top * HChng
CtrlPos(x).Contrl.Width = CtrlPos(x).Width * WChng
CtrlPos(x).Contrl.Height = CtrlPos(x).Height * HChng
Next
End Sub
Contrl As Control
Left As Single
Top As Single
Width As Single
Height As Single
End Type
Dim CtrlPos() As ControlPlaces
Private Sub Form_Load()
ReloadPos
End Sub
Sub ReloadPos()
ReDim CtrlPos(Me.Controls.Count)
Dim Ctrl As Control
Dim Num As Long
For Each Ctrl In Me.Controls
Set CtrlPos(Num).Contrl = Ctrl
CtrlPos(Num).Left = Ctrl.Left
CtrlPos(Num).Top = Ctrl.Top
CtrlPos(Num).Width = Ctrl.Width
CtrlPos(Num).Height = Ctrl.Height
Num = Num + 1
Next
CtrlPos(UBound(CtrlPos)).Left = Me.Left
CtrlPos(UBound(CtrlPos)).Top = Me.Top
CtrlPos(UBound(CtrlPos)).Width = Me.Width
CtrlPos(UBound(CtrlPos)).Height = Me.Height
End Sub
Private Sub Form_Resize()
WChng = Me.Width / CtrlPos(UBound(CtrlPos)).Width
HChng = Me.Height / CtrlPos(UBound(CtrlPos)).Height
For x = 0 To UBound(CtrlPos) - 1
CtrlPos(x).Contrl.Left = CtrlPos(x).Left * WChng
CtrlPos(x).Contrl.Top = CtrlPos(x).Top * HChng
CtrlPos(x).Contrl.Width = CtrlPos(x).Width * WChng
CtrlPos(x).Contrl.Height = CtrlPos(x).Height * HChng
Next
End Sub
追问
这个不行啊,会报错,“Height”是只读属性
还有没有其他解决方法呢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询