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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
VbmasterCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.