Solved

Resizing A Form

Posted on 1998-08-05
9
258 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 6

Expert Comment

by:clifABB
ID: 1467915
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
ID: 1467916
I need to center all the controls, text, and labels within the form for each resolution.
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1467917
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:Amanda080598
ID: 1467918
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
 
LVL 6

Expert Comment

by:clifABB
ID: 1467919
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
ID: 1467920
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
ID: 1467921
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
ID: 1467922
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
ID: 1467923
Hey, who graded this question.  I know I didn't.

Amanda
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

728 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