
Originally Posted by
RobDog888
About the only thing you can probably do is over ride the OnResize event of the form and place your code in there. Also, dependiong on how your needs are for resizing, couldnt you make do with most controls just being anchored so you will only need to size certain ones?
I wish the anchoring thing would work. I guess I'm going to have to make do with knowing that the form is going to be displayed on a big screen for hours/days and that the resize event is only going to happen if the user decides to resize it for no reason. I think this is going to get filed in the "annoying for just me" folder.
I just hate that some VB6 coder made some beautiful form that looked exactly the same no matter what constrained proportions the user set it to and there was no lag in the redraw.
-thanks for your help guys... i guess I'm done beating my head on this wall.
this is what I finally came up with... just a tad bit faster...
Code:
'to save control positions for resizing
Private m_ControlPositions() As ControlPositionType
Private m_FormWid As Single
Private m_FormHgt As Single
' Arrange the controls for the new size.
Private Sub ResizeControls()
Dim i As Integer
Dim ctl As Control
Dim x_scale As Single
Dim y_scale As Single
Dim font_scale As Single
' Get the form's current scale factors.
x_scale = Me.Width / m_FormWid
y_scale = Me.Height / m_FormHgt
font_scale = (y_scale + x_scale / 2)
' Reposition the controls.
i = 0
For Each ctl In Controls
With m_ControlPositions(i)
If ctl.Name <> "MenuStrip1" Then
Dim x As Single
Dim y As Single
Dim h As Single
Dim w As Single
Dim fs As Single
fs = .FontSize * font_scale
x = x_scale * .Left
y = y_scale * .Top
w = x_scale * .Width
h = y_scale * .Height
ctl.Bounds = (New Rectangle(x, y, w, h))
ctl.Font = New Font(ctl.Font.Name, fs)
On Error Resume Next
Else
End If
On Error GoTo 0
End With
i = i + 1
Next ctl