vb界面如何随分辨率改变而改变 10
我做了个VB界面是1024*768的,放在800*600下运行时界面只显示了一部分,放在1280*1024分辨率下控件挤在了左上角,右下角的空间是浪费的,请问有没有什么好...
我做了个VB界面是1024*768的,放在800*600下运行时界面只显示了一部分,放在1280*1024分辨率下控件挤在了左上角,右下角的空间是浪费的,请问有没有什么好办法可以让界面随着分辨率大小改变而做相应的变化呢,让人看起来舒服?
展开
展开全部
别人刚告诉我...
给你个通用的,自己写的。适用于所有带Move方法的控件。
直接粘贴代码即可。
Private Sub Form_Load()
For Each Control In Controls
Control.Tag = Join(Array(Control.Left, Control.Top, Control.Width, Control.Height))
Next
Tag = Join(Array(Width, Height))
End Sub
Private Sub Form_Resize()
Dim sF, sC
sF = Split(Tag)
For Each Control In Controls
sC = Split(Control.Tag)
Control.Move Width / sF(0) * sC(0), Height / sF(1) * sC(1), Width / sF(0) * sC(2), Height / sF(1) * sC(3)
Next
For Each Control In Controls
Control.Tag = Join(Array(Control.Left, Control.Top, Control.Width, Control.Height))
Next
Tag = Join(Array(Width, Height))
End Sub
给你个通用的,自己写的。适用于所有带Move方法的控件。
直接粘贴代码即可。
Private Sub Form_Load()
For Each Control In Controls
Control.Tag = Join(Array(Control.Left, Control.Top, Control.Width, Control.Height))
Next
Tag = Join(Array(Width, Height))
End Sub
Private Sub Form_Resize()
Dim sF, sC
sF = Split(Tag)
For Each Control In Controls
sC = Split(Control.Tag)
Control.Move Width / sF(0) * sC(0), Height / sF(1) * sC(1), Width / sF(0) * sC(2), Height / sF(1) * sC(3)
Next
For Each Control In Controls
Control.Tag = Join(Array(Control.Left, Control.Top, Control.Width, Control.Height))
Next
Tag = Join(Array(Width, Height))
End Sub
参考资料: http://zhidao.baidu.com/question/75786899.html
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private FormOldWidth As Long
Private FormOldHeight As Long
Public Sub ResizeInit(FormName As Form)
On Error Resume Next
Dim Obj As Control
FormOldWidth = FormName.ScaleWidth
FormOldHeight = FormName.ScaleHeight
For Each Obj In FormName
Obj.Tag = Obj.Left & " " & Obj.Top & " " & Obj.Width & " " & Obj.Height & " "
Next
On Error GoTo 0
End Sub
Public Sub ResizeForm(FormName As Form)
On Error Resume Next
Dim Pos(4) As Double
Dim i As Long
Dim TempPos As Long
Dim StartPos As Long
Dim Obj As Control
Dim ScaleX As Double
Dim ScaleY As Double
ScaleX = FormName.ScaleWidth / FormOldWidth
ScaleY = FormName.ScaleHeight / FormOldHeight
For Each Obj In FormName
StartPos = 1
For i = 0 To 4
TempPos = InStr(StartPos, Obj.Tag, " ", vbTextCompare)
If TempPos > 0 Then
Pos(i) = Mid(Obj.Tag, StartPos, TempPos - StartPos)
StartPos = TempPos + 1
Else
Pos(i) = 0
End If
Obj.Move Pos(0) * ScaleX, Pos(1) * ScaleY, Pos(2) * ScaleX, Pos(3) * ScaleY
Next
Next
On Error GoTo 0
End Sub
Private Sub Form_Load()
Call ResizeInit(Me)
End Sub
Private Sub Form_Resize()
Call ResizeForm(Me)
End Sub
Private FormOldHeight As Long
Public Sub ResizeInit(FormName As Form)
On Error Resume Next
Dim Obj As Control
FormOldWidth = FormName.ScaleWidth
FormOldHeight = FormName.ScaleHeight
For Each Obj In FormName
Obj.Tag = Obj.Left & " " & Obj.Top & " " & Obj.Width & " " & Obj.Height & " "
Next
On Error GoTo 0
End Sub
Public Sub ResizeForm(FormName As Form)
On Error Resume Next
Dim Pos(4) As Double
Dim i As Long
Dim TempPos As Long
Dim StartPos As Long
Dim Obj As Control
Dim ScaleX As Double
Dim ScaleY As Double
ScaleX = FormName.ScaleWidth / FormOldWidth
ScaleY = FormName.ScaleHeight / FormOldHeight
For Each Obj In FormName
StartPos = 1
For i = 0 To 4
TempPos = InStr(StartPos, Obj.Tag, " ", vbTextCompare)
If TempPos > 0 Then
Pos(i) = Mid(Obj.Tag, StartPos, TempPos - StartPos)
StartPos = TempPos + 1
Else
Pos(i) = 0
End If
Obj.Move Pos(0) * ScaleX, Pos(1) * ScaleY, Pos(2) * ScaleX, Pos(3) * ScaleY
Next
Next
On Error GoTo 0
End Sub
Private Sub Form_Load()
Call ResizeInit(Me)
End Sub
Private Sub Form_Resize()
Call ResizeForm(Me)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
注意控件随窗口大小改变
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询