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?
 
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
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
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
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
(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.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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.
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
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.
0
 
jpp1jpp1Author Commented:
Thx for your effort
0
 
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.
0
 
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.