Board index » delphi » Resizing a form according to monitor resolution ?

Resizing a form according to monitor resolution ?

Isn't there a screen.width /height property available? You could then read
it and adjust the size of your form in the oncreate-eventhandler of your
form.

/Jacob

 

Re:Resizing a form according to monitor resolution ?


Hi !

What would be a proper way to resize a form to make it fit on monitors using
different resolutions.

I have designed a form to fit on a monitor using a resolution of 1024 x 768,
but this form is far to large for use on a monitor using a resolution of 640
x 480.

Thanks in advance.

Anders Hundborg

Re:Resizing a form according to monitor resolution ?


Quote
> What would be a proper way to resize a form to make it fit on monitors using
> different resolutions.
> I have designed a form to fit on a monitor using a resolution of 1024 x 768,
> but this form is far to large for use on a monitor using a resolution of 640
> x 480.

Anders,

in the forms OnCreate event call

  SystemPArametersInfo( SPI_GETWORKAREA, 0, @aRect, 0 );

Check the returns aRect dimensions against your forms width and height, if
they are smaller do a BoundsRect := aRect; and set the forms AutoScroll
property to true. This makes it sprout scrollbars, does not look too hot but
at least the user can reach any control on your form.

An alternate approach would be to try to resize the controls but that only
works if you have only few controls that cover a large area, e.g. memos,
richedits, grids. You can design you form with judicious use of Anchor or
Align properties in controls, to make the control adjustment automatic.
But if the form contains lots of edits, buttons, comboboxes etc. resizing
will not work well. Resist the temptation to try to resize anything by the
ratio of actual/designtime size, the form will most probably become unusable
if you do that since the fonts become to small.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Other Threads