Resizing forms at runtime
Jeff,
Here's working code that keeps a control mapped to the form as it's resized.
It also deals with minimized forms.
' (General) (Declarations)
' API Interface Functions and Data types
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long,
lpRect As RECT) As Long
Private Sub Form_Resize()
Dim WindowSize As RECT
If GetClientRect(Me.hwnd, WindowSize) <> 0 Then
ImgEdit1.Height = WindowSize.Bottom * Screen.TwipsPerPixelY
ImgEdit1.Width = WindowSize.Right * Screen.TwipsPerPixelX
End If
' Adjust top for toolbar
If tbToolBar.Visible = True Then
ImgEdit1.Top = tbToolBar.Height
Else
ImgEdit1.Top = 0
End If
' Adjust height
ImgEdit1.Height = Abs(ImgEdit1.Height - ImgEdit1.Top)
If sbStatusBar.Visible = True Then ImgEdit1.Height = ImgEdit1.Height -
sbStatusBar.Height
ImgEdit1.FitTo 0
End Sub
Quote:
> If I have a form with controls on it and allow the user to maximize the
> form what do I have to do to then have the controls spread out over the
> entire form and not just stay in the corner where they began. I hope
> this is clear.