Board index » delphi » Forms under different screen resolutions - Help please

Forms under different screen resolutions - Help please

I have created an application with quite busy forms. I develop the
application on a screen resolution of 1024x768.

When I run the application on screens of other resolutions, with other
screen cards etc.,  the forms get messed up, by this I mean that the
external size seems to get reduced and therefore masks some of the
internal pannels and data.

Am I missing a setting somewhere which allows re-configuration for
different resolutions?

Thanks In Advance

Brian
--
Brian Childs

 

Re:Forms under different screen resolutions - Help please


I have created an application with quite busy forms. I develop the
application on a screen resolution of 1024x768.

When I run the application on screens of other resolutions, with other
screen cards etc.,  the forms get messed up, by this I mean that the
external size seems to get reduced and therefore masks some of the
internal pannels and data.

Am I missing a setting somewhere which allows re-configuration for
different resolutions?

Thanks In Advance

Brian
--
Brian Childs

Re:Forms under different screen resolutions - Help please


Brian Childs <br...@vizef.demon.co.uk>

Quote

> I have created an application with quite busy forms. I develop the
> application on a screen resolution of 1024x768.

> When I run the application on screens of other resolutions, with other
> screen cards etc.,  the forms get messed up, by this I mean that the
> external size seems to get reduced and therefore masks some of the
> internal pannels and data.

> Am I missing a setting somewhere which allows re-configuration for
> different resolutions?

> Thanks In Advance

> Brian
> --
> Brian Childs

Hello !
 Screen-resolution and distorted form layout are common problems for
many applications. Thers is no "magic" single line code to solve the
problem, but here are some guidelines:
1. The Form's 'Scaled' property set to TRUE (Default)
2. Use only true-type fonts and restrict the number of fonts in use
to a minimum. Also try to avoid large values for the font's size.
3. My experience is that grids and headerControls cause a lot of
scaling troubles. I don't know why, but sometimes the column-headers in
DBgrids scales wrong if you set font and attributes at design time.
To solve this, set the grid's 'ParentFont' = TRUE. If you need other
colors and fonts, put some code for these settings in the OnShow (or
OnCreate) event. If you use headerControls, make sure that the sections
always have the same width as the columns on the component it controls.
4. Make room around the components. If you design with 1024x768 and
make some nice forms where field and labels are tight together, this
will not look nice anymore on lower resolutions. It looks like the
components climb on each other.
5. Try to minimum the use of different colors. Remember that the color-
settings (i.e clWindow) could have any values on other machines. Then
the total color-layout of the form could be very "phsycedelic"
6. Set the property 'Align' to some other value than alNone wherever
you can. If you forget this, components will not always show up where
expected. And more, the form layout will not scale properly when the
form is resized (by the user).

To simulate other resolutions, you can use the method changeScale(M,D)
in the forms OnShow method. If M and D (integers) are equal, then the
form appears as designed. If you reduce M , the form is scaled down
(i.e 800/1024). This method is not accurate, but gives you a feeling of
how the form will look like.

 Hope this can help.

Regards
Atle Markeng
DataMar, Oslo -Norway

Re:Forms under different screen resolutions - Help please


I have seen several freeware components that resizes your forms (and
everything upon it) under different screen resolutions. Search on the
web (delphi freeware) to find one.

regards

Jonas Ahlgren
Libro datakonsult
Sweden

Re:Forms under different screen resolutions - Help please


I posted this a few days ago to another query, maybe this will help.

Scaling Forms in Different Screen Resolutions

I have tried various methods of managing form scaling in Delphi 1, and
have come down to the following method, which seems to work consistently.

As each form is created, the following is called either on creation, or on
activation (provided the form is freeed after use).

Two Global variables are used: DesignWidth and DesignHeight, corresponding
to the resolution used in program design. (I use 800 x 600).

It is important to set some Form properties correctly:
1. Scaled must be False;
2. AutoScroll may need to be False (I havent tested True);
3. Set ParentFont := False for all components, else they get scaled
multiple times.

It is essential that you never open the Form in design mode in any other
resolution, since then Delphi rescales, and since this is an integer maths
function, rounding errors persist.

procedure ScaleForm(aform:TForm; awidth, aheight:Integer);
var
        i:Integer;

begin
  if (MainForm.ScreenX <> DesignWidth) then

                { resize the form to correct resolution }
                with aform do begin
                        Height := (aheight * Main.ScreenY) div DesignHeight;
                        Width := (awidth * Main.ScreenX) div DesignWidth;
                  for i := 0 to Pred(ComponentCount) do begin

                                { Repeat this block for each component type used in the form }
                                if Components[i] is TPanel then
                                        with Components[i] as TPanel do begin
                                                SetBounds((Left * Main.ScreenX) div DesignWidth,
                                (Top * Main.ScreenY) div DesignHeight,
                                                (Width * Main.ScreenX) div DesignWidth,
                        (Height * Main.ScreenY) div DesignHeight);
                                                Font.Size := (Font.Size * Main.ScreenY) div DesignHeight;
                                        end;

                                end;
end;    { ScaleForm }

ScaleForm is a general utility procedure, and you need just one copy in
the program.

It is important to do the calculation (Left * Main.ScreenX) div
DesignWidth in that order (force multiply before div) to give the minimum
rounding error.

-----------------------------------------------------------------
{*word*106}.glo...@ukonline.co.uk
-----------------------------------------------------------------

Re:Forms under different screen resolutions - Help please


Quote
Brian Childs <br...@vizef.demon.co.uk> wrote:
>I have created an application with quite busy forms. I develop the
>application on a screen resolution of 1024x768.
>When I run the application on screens of other resolutions, with other
>screen cards etc.,  the forms get messed up, by this I mean that the
>external size seems to get reduced and therefore masks some of the
>internal pannels and data.
>Am I missing a setting somewhere which allows re-configuration for
>different resolutions?

Make sure all the different panels, edit controls, etcetera are using
scalable fonts...this can cause problem when changing resolutions.

JE McTaggart
t...@iguana.ruralnet.net

Other Threads