by Don (3 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Wed 22nd December 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Resize form controls, when Maximize.
API Declarations
Discovered that not all controls will resize automatically when a form maximizes. This is simply because that they don't get enough time too. To get around this you simply make a procedure which gets called by a timer control which enables and disables when ever the form is resized. It came in handy for me and hope it comes in handy for you. Merry HoHo's.
2/On the main form add a timer control. set the time to "1" and the enabled to "false". Also add a textbox to the main form.
3/Either create a new module or add this code to your current form.
4/Create a procedure something like the following.
Public Sub Resize_Form()
With Form1
if .WindowsState<>1 then
Text1.Left=.ScaleLeft
Text1.Top=.ScaleTop
Text1.Width=.ScaleWidth
Text1.Height=.ScaleHeight
End If
End With
End Sub
4/Under the timer control add the following code.
Sub Timer1_Time()
Resize_Form
Timer1.Enabled=False
End Sub
5/Under the main form resize event add the following code.
Sub Form1_Resize()
Timer1.Enabled=True
End Sub
6/Run the program and watch the form automatically get resized.