look for advices in resizing forms

Posted on 2003-03-20
Medium Priority
Last Modified: 2010-05-01
I design my forms according to my screen resolution and dimentions. but when I install the same project on other PC I find that the forms and its controls are not at the same location as mine because of the diffrences of screen resolution and settings. are there any common way or advices to solve the situation?
if there is a code , please show it

Question by:GouGou
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

Expert Comment

ID: 8176079
If you're just after form position, use the code...

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

or replace Me with any form you need... or put it in a sub like..

Public Sub CenterForm(frmCenter As Form)
frmCenter.Left = (Screen.Width - frmCenter.Width) / 2
frmCenter.Top = (Screen.Height - frmCenter.Height) / 2
End Sub

then you can do..

CenterForm Me  or..
CenterForm frmMain or whatever you need to center


Author Comment

ID: 8176255
thanx for your answer.
But this is OK for the form. my problem is about the controls' position which may being cut in large screen settings for example 640*480 is completely different than 1024*768 and so on
LVL 38

Expert Comment

ID: 8176340
Best practice is to design for the smallest screen your program will run on.  Typically, this is 800x600, but if your customer has some 640x480 workstations, then you should try to accomodate them by designing for this size.  If you find you have too many controls to fit the smaller size, then you may have to use a tabbed dialog or other space saver to free up onscreen real estate.  

There are resizers available as third party controls, but they can result in some odd looking screens.  
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 44

Expert Comment

ID: 8176421
I agree 100% with PaulHews....I ALWAYS design the Application for the Absolute SMALLEST resolution that will EVER be used for the program.  That way I am sure about the placement of controls, and the real amount of available space on the screen.  That also forces the developer to be realistic about the number of controls that are placed on any one screen.

That does NOT mean, however, that I do not attempt to convince the end users that it is in their own best interest to seriously consider upgrading CRTs to a higher resolution, if at all possible.


Expert Comment

ID: 8176538
I agree with the statements so far.

But one further consideration if your forms are covered in things like pictures charts or lists these can be easly resized to fit the form. I typically design to types of form (with respect to your problem).

1) Fixed forms, that cannot be resized these typically contain many textboxes and combos.

2) Full screen forms, these typically will resize but not always.  these forms tend to consist of list controls, grids, pictures, charts and treeviews etc.

The Forms resize event is used to control the size of the list portions.

In theory you could make all forms resizeable but often there is absolutley no need unless you like blank spaces.

Expert Comment

ID: 8178877
I'm not sure how you get the screen resolution from the computer but there is a way. Check for the users resolution and resize and move all of your buttons etc. throught the code.
LVL 13

Accepted Solution

sameer2010 earned 200 total points
ID: 8184398
The best solution for this will be something like this:
RELATIVE POSITIONING of all controls in the form!!
For this, u can use SCALE command to decide corner coordinates. I generally use upper left as -1,-1 and lower right as 1,1 so that centre is 0,0. Now, place ur controls on the form always with respect to this system. Because corners will be adjusted automatically runtime, remianing distances will also get adjusted giving no problems of positions, and about sizes also you should decide some scale depending on the corner positions of forms. This way ur form will be displayed same on any machine!! Hope this helps u

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

762 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