I changed resolutions and ReSize didn't work properly

Last updated: January 21, 2007

Typical question: I authored a form in 800 X 600 that is 9000 by 6000 twips and therefore covers about 3/4 of the physical width of the screen and 2/3 of the height of the physical width of the screen. When I change resolutions to 640 X 480 the form still comes up at 9000 by 6000 twips and takes up almost all of the physical screen. When I change resolutions to 1124 X 768 the form once again comes up at 9000 by 6000 twips and takes up only a small portion of the physical screen. I thought ReSize would alter the size of my form to keep it in proportion to the physical size of the monitor. Am I doing something wrong?

Answer: ReSize only changes the size of the controls contained in a form. It never changes the size of the form itself. You can achieve the effect you are looking for by adding a few lines of code to the Form_Load event of your form. In the example above you can make the form always come up at 3/4 the width of the physical screen by adding the following code to the Form_Load event:

Form1.Width = Screen.Width * 3 / 4

Positioning the form is a little trickier but only requires two more lines of code:

Form1.Top = Screen.Height * 0.10
Form1.Left = Screen.Width * 0.10

In this case you sync the form top and left to the height and width of the physical screen - not the top and left of the physical screen which of course is always 0,0. You will probably want to multiply by a fairly small number such as 0.10 which will make the origin of the form about one tenth of the physical height and width of the screen. You may need to do some experimenting to come up with the desired values.

Copyright 2007 by Larcom and Young.
All rights reserved. Revised: January 21, 2007.