Resizing A Form

How to automatically resize the forms of a VB project when the size of the monitor changes?

Amanda
Amanda080598Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
manuelfrancisConnect With a Mentor Commented:
the question is not very much clear...
because the first question is itself is not correct (How to automatically resize the forms of a VB project when the size of the monitor changes? )
nothing will change if you changes the monitor from  14 to 17 inch. the screen resolution is the thing that changes the behavior of the controlls. you can use the 640 / 480 resolution at both monitors there will not be any change in the position at all.

Form_Load()
Dim I

      For I = 0 To me.Controls.Count - 1
            If TypeOf me.Controls(I) Is Not Menu Then
                  me.Controls(I).left=%*Screen
            End If
      Next I

End if

You can get the controlls in a form by the above code.
if you add this code in the form load event of the Form the from there you can possion the any contoll referrance to the screen.

Hope you can modify this code....
or else i can get you a detailed answer...
0
 
clifABBCommented:
Do you mean when the resoltion changes?

When your form loads, check the resolution of the screen with the properties:
  Screen.Width and Screen.Height.
Make your forms a percentage of that value.

This code will size a form to 1/4 of the screen no matter what the resolution:
Private Sub_Load()
  Form1.Height = Screen.Height / 2
  Form1.Width = Screen.Width / 2
End Sub
0
 
Amanda080598Author Commented:
I need to center all the controls, text, and labels within the form for each resolution.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
clifABBCommented:
Again, it's a percentage of the screen dimensions.

OK, here's an idea.  Use a picturebox on your form as a container for all the controls on your form.  Place all the controls, text, and labels which were on the form onto the picturebox (you can use cut & paste wich will keep the controls position relative to each other).  Placing your controls on the picture box will allow you to move all the controls at one time rather than individually.  Finally, after you resize your form in my above example, use this code:
  Picture1.Move (Me.Width - Picture1.Width) / 2, (Me.Height - Picture1.Height) / 2

You might put this code in the form's resize event so that, whenever the form is resized, the controls stay centered.
0
 
Amanda080598Author Commented:
Without programming each control individually - I need to be able to use the application on a 14 inch and a 17 inch screen.  The controls should not change positions with either screen size.  Using the Private Sub_Load()
  Form1.Height = Screen.Height / 2
  Form1.Width = Screen.Width / 2
End Sub
does not solve the problem.

0
 
clifABBCommented:
Unfortunately, there is no way (that I know of) to tell where, in inches, a position on the screen is.

Within a form this is possible if you change the ScaleMode property to inches.  However, there is no ScaleMode property for the screen object.

You should reject my answer in case there is another expert who does know a way.

Good luck.
0
 
cymbolicCommented:
A control called the VS Flex control from Videosoft will automatically take care of proportionally resizing all your controls on the form when the control is resized.  This process also retains all relative spacing and positioning as well.  You can download a working demo from the Videosoft site on the web.
0
 
clifABBCommented:
cymbolic:
The control you refer to is not VSFlex (Videosoft's grid control), it's VSOCX (or sold alone as ElasticLight).
I am familiar with this control and it will resize based on resolution, however I don't think it will resize based on the physical size of the monitor which is what Amanda wants.
0
 
Amanda080598Author Commented:
Hey, who graded this question.  I know I didn't.

Amanda
0
All Courses

From novice to tech pro — start learning today.