15-06-13, 07:49 PM
Public Class Form1
Dim ProportionsArray() As CtrlProportions
Private Structure CtrlProportions
Dim HeightProportions As Single
Dim WidthProportions As Single
Dim TopProportions As Single
Dim LeftProportions As Single
End Structure
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Me.TextBox2.Anchor = AnchorStyles.Top And AnchorStyles.Bottom And AnchorStyles.Left And AnchorStyles.Right
Informload()
End Sub
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
Resizeform()
End Sub
Sub Informload()
On Error Resume Next
Application.DoEvents()
ReDim ProportionsArray(0 To Controls.Count - 1)
For I As Integer = 0 To Controls.Count - 1
With ProportionsArray(I)
.HeightProportions = Controls(I).Height / Height
.WidthProportions = Controls(I).Width / Width
.TopProportions = Controls(I).Top / Height
.LeftProportions = Controls(I).Left / Width
End With
Next
End Sub
Public Sub Resizeform()
On Error Resume Next
For I As Integer = 0 To Controls.Count - 1
Controls(I).Left = ProportionsArray(I).LeftProportions * Me.Width
Controls(I).Top = ProportionsArray(I).TopProportions * Me.Height
Controls(I).Width = ProportionsArray(I).WidthProportions * Me.Width
Controls(I).Height = ProportionsArray(I).HeightProportions * Me.Height
Next
End Sub
End Class
Dim ProportionsArray() As CtrlProportions
Private Structure CtrlProportions
Dim HeightProportions As Single
Dim WidthProportions As Single
Dim TopProportions As Single
Dim LeftProportions As Single
End Structure
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Me.TextBox2.Anchor = AnchorStyles.Top And AnchorStyles.Bottom And AnchorStyles.Left And AnchorStyles.Right
Informload()
End Sub
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
Resizeform()
End Sub
Sub Informload()
On Error Resume Next
Application.DoEvents()
ReDim ProportionsArray(0 To Controls.Count - 1)
For I As Integer = 0 To Controls.Count - 1
With ProportionsArray(I)
.HeightProportions = Controls(I).Height / Height
.WidthProportions = Controls(I).Width / Width
.TopProportions = Controls(I).Top / Height
.LeftProportions = Controls(I).Left / Width
End With
Next
End Sub
Public Sub Resizeform()
On Error Resume Next
For I As Integer = 0 To Controls.Count - 1
Controls(I).Left = ProportionsArray(I).LeftProportions * Me.Width
Controls(I).Top = ProportionsArray(I).TopProportions * Me.Height
Controls(I).Width = ProportionsArray(I).WidthProportions * Me.Width
Controls(I).Height = ProportionsArray(I).HeightProportions * Me.Height
Next
End Sub
End Class

