Option Explicit On
Public Class Form3
Private ObjOldWidth As Long
Private ObjOldHeight As Long
Private ObjOldFont As Double
Public Sub ResizeInit(ByVal FormName As Form)
Dim Obj As Control
ObjOldWidth = Me.Width
ObjOldHeight = Me.Height
ObjOldFont = Me.Font.Size / ObjOldHeight
On Error Resume Next
For Each Obj In Me.Controls
Obj.Tag = Obj.Left & " " & Obj.Top & " " & Obj.Width & " " & Obj.Height & " "
Next Obj
On Error GoTo 0
End Sub
Public Sub ResizeForm(ByVal FormName As Form)
Dim Pos(4) As Double
Dim i As Long, TempPos As Long, StartPos As Long
Dim Obj As Control
Dim ScaleX As Double, ScaleY As Double
ScaleX = Me.Width / ObjOldWidth
ScaleY = Me.Height / ObjOldHeight
On Error Resume Next
For Each Obj In Me.Controls
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.Left = Pos(0) * ScaleX
Obj.Top = Pos(1) * ScaleY
Obj.Width = Pos(2) * ScaleX
Obj.Height = Pos(3) * ScaleY
Obj.Font = New Font(ObjOldFont.ToString, Me.Height)
Next i
Next Obj
End Sub
Private Sub Form3_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Call ResizeInit(Me)
Dim s As Screen
Me.FormBorderStyle = FormBorderStyle.None
s = Screen.PrimaryScreen
Me.Size = New Size(s.Bounds.Width, s.Bounds.Height)
Me.Top = s.Bounds.Height / 2 - Me.Height / 2
Me.Left = s.Bounds.Width / 2 - Me.Width / 2
End Sub
Private Sub Form3_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
Call ResizeForm(Me)
End Sub
End Class
这段代码有啥米问题。。。为啥tabcontrol会变得只剩个大方框。。。标签、里面的内容和textbox都没了。。。此页上的button也木有字。另一个form里就是字变得超级大,原来是1好,全屏后直接整个屏幕上就一个字,还显示不全。。。求解!跪求!