Home > Net >  About the MDI window control change with the window size
About the MDI window control change with the window size

Time:09-17

Good warrior, I looking for the following code on the net gain control function change with the window size, but found the following problems, I ask you
I put the following code in each mdi window, open the first mdi window to maximize way no problem, then has been to maximize the way to open the second mdi window control cannot be covered, or when the normal design size, closed again opened also is bad to use, should be how to solve it, thank you
Private Sub setTag (ByVal obj As Object)
For Each con As Control In obj. Controls,
Con. The Tag=con. Width & amp; ":" & amp; Con. Height & amp; ":" & amp; Con. Left & amp; ":" & amp; Con. Top & amp; ":" & amp; Con. The Font. The Size

'if it is a container control recursive continue to record
If con. Controls. Count & gt; 0 Then
SetTag (con)
End the If
Next
End Sub

'recursive reset controls the size and location of the
Private Sub setControls (ByVal newx As Single, ByVal newy As Single, ByVal obj As Object)

For Each 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

'font scaling, zoom font
Dim currentSize As Single=(mytag newy (1) * * mytag (4))/mytag (1)
Con. The Font=New Font (con. The Font. The Name, currentSize, con. The Font, Style, con. The Font. The Unit)

'if it is a container control recursive continue to zoom
If con. Controls. Count & gt; 0 Then
SetControls (newx, newy, con)
End the If
Next
End Sub
Private Sub Form_Resize (sender As Object, As EventArgs e) Handles MyBase. Resize
Try
'get the size of the form now, then calculate according to the original size scaling
'MsgBox (CStr (Me) Width) & amp; "-" & amp; CStr (Me, Height))
Dim newx As Single=Me. Width/x
Dim newy As Single=Me. Height/y
SetControls (newx, newy, Me)
Catch the ex As Exception

End the Try
End Sub
Private Sub Form_Load (sender As Object, As EventArgs e) Handles MyBase. Load
'control over the window size adjustment
X=Me. Width
Y=Me. Height
SetTag (Me)
End Sub
  • Related