Form Resize

I'm looking for generic VB code (I want to be able to use the code on almost any form if possible) that will resize and move all controls on a Form_Resize event.
jasonboetcherAsked:
Who is Participating?
 
VbmasterConnect With a Mentor Commented:
There is plenty of code samples on this topic at www.planetsourcecode.com, just go to the Visual Basic area and search for Resize.
0
 
mmipsCommented:
This example shows using a list view and a treeview on a form.

Define the vars in the on load event in the declarations section

in the on load event:

'some screen coordinates to allow resizing of controls when window is resized
lViewHeight = frame.ListView1.Height
lViewWidth = frame.ListView1.Width
lViewLeft = frame.ListView1.Left
tViewHeight = frame.TreeView1.Height
tViewWidth = frame.TreeView1.Width
frmWidth = frame.ScaleWidth
frmHeight = frame.ScaleHeight


in the resize event:

Dim scaleX As Single
Dim scaleY As Single

If frame.ScaleWidth > 0 Then
    scaleX = (frmWidth / frame.ScaleWidth)
Else
    scaleX = 1
End If

If frame.ScaleHeight > 0 Then
    scaleY = frmHeight / frame.ScaleHeight
Else
    scaleY = 1
End If

frame.ListView1.Move lViewLeft / scaleX, frame.ListView1.Top, lViewWidth / scaleX, lViewHeight / scaleY
frame.TreeView1.Move frame.TreeView1.Left, frame.TreeView1.Top, _
        tViewWidth / scaleX, (tViewHeight / scaleY)
0
 
jasonboetcherAuthor Commented:
Thanks for the quick response.
0
 
jasonboetcherAuthor Commented:
There were some great examples at that site.  The free form resize ocx available for download there works great.
0
 
VbmasterCommented:
Ya that site rules when you are lookin' for these kind of 'standardized' codes. ,)
0
All Courses

From novice to tech pro — start learning today.