Private Sub Form_Resize()
Static lngWidth As Long
Static lngHeight As Long
Dim ratex As Single
Dim ratey As Single
If lngWidth = 0 Or lngHeight = 0 Then
lngWidth = Me.Width
lngHeight = Me.Height
Else
ratex = lngWidth / Me.Width
ratey = lngHeight / Me.Height
If ratex > 0.1 And ratey > 0.1 And Me.WindowState <> 1 Then
lngWidth = Me.Width
lngHeight = Me.Height
resizeControl Me, ratex, ratey
End If
End If
End Sub
Private Sub resizeControl(resizeForm As Form, ByVal ratex As Single, ByVal ratey As Single)
Dim ctr As Control
On Error Resume Next
For Each ctr In resizeForm.Controls
ctr.Left = ctr.Left / ratex
ctr.Top = ctr.Top / ratey
ctr.Width = ctr.Width / ratex
ctr.Height = ctr.Height / ratey
Next
End Sub
还要再考虑窗体的最小值,否则是不能还原的。