Public Class
Form1
Inherits
System.Windows.Forms.Form
'****************************************
'Place this code
as Formwise global *
Dim c(6, 0) As String '*
Dim xx, yy As Long '*
'****************************************
Private Sub Form1_Load(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'**********************************************************
'Place this
code in the Form_Load Event
'*
xx = Me.ClientSize.Width '*
yy = Me.ClientSize.Height '*
InitializeResize(Me, xx, yy) '*
'**********************************************************
End Sub
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles
MyBase.Resize
'***********************************************
'Place this
code in the Form_Resize Event '*
Dim sX,
sY As Double '*
Dim j As Integer '*
'*
On Error Resume Next '*
sX = Me.ClientSize.Width / xx '*
sY = Me.ClientSize.Height / yy '*
For j =
1 To c.GetUpperBound(1) '*
ResizeControls(Me, c(0, j), j, sX, sY) '*
Next
j '*
'***********************************************
End Sub
'******** Add
this sub to the Form **********************************************
Private Sub InitializeResize(ByVal ct As Object, ByVal w As Long, ByVal h As Long)
Dim i,
k As Integer
Dim ctl
As Control
For Each ctl In
ct.Controls
If
ctl.Name = "" Then Exit For
k = c.GetUpperBound(1)
ReDim
Preserve c(6, k + 1)
c(0, k +
1) = ctl.Name
c(1, k +
1) = ctl.Left
c(2, k +
1) = ctl.Top
c(3, k +
1) = ctl.Width
c(4, k +
1) = ctl.Height
c(5, k +
1) = ctl.Font.Size
c(6, k +
1) = ctl.Font.Style
i = ctl.Controls.Count
If
i > 0 Then
InitializeResize(ctl,
ctl.Width, ctl.Height)
End
If
Next
ctl
End Sub
'****** Add this
sub to the Form **************************************************
Private Sub ResizeControls(ByVal cm As Object, ByVal s As String, ByVal n As Integer, ByVal x As Double, ByVal y As Double)
Dim i,
k As Integer
Dim ct As Control
For Each ct In
cm.controls
If
ct.Name = s Then
ct.Left = c(1,
n) * x
ct.Top = c(2,
n) * y
ct.Width = c(3,
n) * x
ct.Height = c(4,
n) * y
If
x < y Then
ct.Font = New System.Drawing.Font(ct.Font.Name,
c(5, n) * x)
Else
ct.Font = New System.Drawing.Font(ct.Font.Name,
c(5, n) * y)
End
If
ct.Font = New System.Drawing.Font(ct.Font,
c(6, n))
Exit For
Else
ResizeControls(ct,
s, n, x, y)
End
If
Next
End Sub
End Class