Public Class FRMDL
Dim x As Single = 0
Dim y As Single = 0
Private Sub frmdl_load (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles MyBase.Load
x = Me.Width
y = me.height
Settag (Me)
End Sub
' recursively takes the original size and position of the control, using tag to record
Private Sub Settag (ByVal obj as Object)
For all con as control in obj. Controls
Con. Tag = con. Width & ":" & con. Height & ":" & con. Left & ":" & con. Top & ":" & con. Font.Size
' If it is a container control, it continues to record recursively
If con. Controls.Count > 0 Then
Settag (Con)
End If
Next
End Sub
' Recursively reset the size and position of the control
Private Sub Setcontrols (ByVal newx as single, ByVal newy as single, ByVal obj as Object)
For all con as control in obj. Controls
Con. AutoSize = False
Dim MyTag () as String = con. Tag.ToString.Split (":")
Con. Width = MyTag (0) * newx
Con. Height = MyTag (1) * Newy
Con. left = MyTag (2) * NEWX
Con. top = MyTag (3) * Newy
' Calculate font scaling, scaling fonts
Dim CurrentSize as Single = (MyTag (1) * Newy * MYTAG (4))/MyTag (1)
Con. Font = New font (con. Font.Name, CurrentSize, _
Con. Font.style, Con. Font.unit)
' If it is a container control, the recursion continues to scale
If con. Controls.Count > 0 Then
Setcontrols (newx, newy, con)
End If
Next
End Sub
Private Sub frmdl_resize (ByVal sender as Object, ByVal e as System.EventArgs) Handles me.resize
' Get the size of the form now, and then calculate the zoom scale based on the original size
Dim newx as Single = me.width/x
Dim Newy as Single = me.height/y
Setcontrols (Newx, Newy, Me)
End Sub
End Class