Solved

Resizing A Form

Posted on 1998-08-05
9
253 Views
Last Modified: 2010-05-03
How to automatically resize the forms of a VB project when the size of the monitor changes?

Amanda
0
Comment
Question by:Amanda080598
9 Comments
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
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
 

Author Comment

by:Amanda080598
Comment Utility
I need to center all the controls, text, and labels within the form for each resolution.
0
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
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
 

Author Comment

by:Amanda080598
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 6

Expert Comment

by:clifABB
Comment Utility
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
 
LVL 9

Expert Comment

by:cymbolic
Comment Utility
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
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
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
 

Accepted Solution

by:
manuelfrancis earned 50 total points
Comment Utility
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
 

Author Comment

by:Amanda080598
Comment Utility
Hey, who graded this question.  I know I didn't.

Amanda
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now