Changing startup position of a form display

Let's say i have a huge form (almost full screen) and by default I want to load it in a compact mode ( a expand button would show it in full-size). Lowering height and width properties at loadup works fine but additionaly I want the compact mode to display a part of the form that is not at (0,0) instead it's somewhere in the middle. Changing top and left doesn't work, ir still starts drawing the form from 0,0 (top left).

I hope I made myself understandable. :P
jpp1jpp1Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Jim HornMicrosoft SQL Server Data DudeCommented:
Form_Open

With frmYourForm
   .Left =   'Set the #'s here, in twips = 1/1440th of an inch
   .Top =
   .Width =
   .Height =
End With

Knock yourself out...
-Jim
Jim HornMicrosoft SQL Server Data DudeCommented:
(slight correction, I spent too much time doing Access)

Private Sub Form_Load()

With frmYourFormName
   .Left =   'Set the #'s here, in twips = 1/1440th of an inch
   .Top =
   .Width =
   .Height =
End With

End Sub

'Also, if you want to change the form's shape at runtime, I believe you can only do this by showing/hiding contents at the bottom/right of the form by adjusting .Width and .Height, as it will always anchor itself at 0,0.
jpp1jpp1Author Commented:
No... Let's split the whole form in 9 parts:

   1  2  3
   4  5  6
   7  8  9

I want the compact form to just show block 5.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Jim HornMicrosoft SQL Server Data DudeCommented:
I think all that's possible is to dispay 1 or 1245 or 123456789, and not 5.   I'll step back and see if another expert has a solution for you.
jpp1jpp1Author Commented:
Thx for your effort
Carl TawnSystems and Integration DeveloperCommented:
I'm afraid jimhorn is right.  Form resizing in VB occurs in the lower right corner.

The only way to do waht you want would be to reposition all of the controls on the form so that the bit you want appears in the middle when the form is in "compact" mode.
Mark_FreeSoftwareCommented:


the scaleleft is what you are looking for

but be aware:

when you change this, the left of the controls changes with it,
so first change scaleleft and then position controls
iHadiCommented:
An easy solution is to add a picturebox (as a container) on your huge form and cut all the other controls on your form and paste them in the picturebox.

Now when your form is in compact mode you can control the parts that will be visible by changing the picturebox's left and top to suit your needs.

As an example, to show the center of the picture box:

Picture1.Left = (Me.Width - Picture1.Width) / 2
Picture1.Top = (Me.Height - Picture1.Height) / 2

This will position the container picturebox (picture1) in the center of the form.
You can add this code in the form_resize event

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
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.