If the PC where the apps runs have 800x600 and the apps was develop using
1024x768 the apps doesn't look good in screen.
Is there any way to handle this, to make the apps to resize all objects
depending on the Screen Resolution of the PC where the apps run.
HTH,
SenthilV
=====
There are loads of components on the market check out the Delphi Super Page.
I
have actually written my own but it's still a little ropey on a lot of
things
(such as tabpages etc).
To find out what resolution you are dealing with use Screen.pixelsperinch
(*).
This will tell you whether you are in 96 or 120 ppi mode which is small or
large
fonts respectively.
Then the Screen.width and Screen.Height (**) tell you the resolution such as
1024 by 768 etc.
To resize a form on startup or all the time you would need to know the
design
time ppi (*) and the X direction (**). Then when you start the application
in
another screen mode use the screen variables to work out a scale to use such
as
FScaleX := (CurrentX / FDesignX) * (FDesignRes / CurrentRes) ;
so if you design at 1024 96ppi and run at 800 96ppi then the scale would be
800/1024. Now multiply this by 100 to convert to a percentage and you can
use
the ScaleBy routine provided by delphi ie. ScaleBy(scale, 100); { note
percentage values being used} or you can use ScaleBy(CurrentX, FDesignX).
ScaleBy will scale all the components.
If the running resoulution is 120 however, then the scale would be
(800/1024)/(96/120) slightly smaller than would be expected, but this will
keep
your app the same relative size to the screen in all resolutions.
You should also use TrueType fonts for scaling properly. You can also use
the
Scaled property in the forms. This will correctly scale for 120/96ppi
problem
but will not do so for the form or when you resize.
You can use ScaleBy from the Oncreate or from the OnResize event. This
method is
not perfect and there are things that will not scale such as the lines and
columns in a StringGrid or the TabFont on the TTabbedNotebook pages etc etc.
You also need to scale the form itself though.
Hope this helps, Martin
--
Martin Walters
GeoLogic Software
=====
"Guillermo Sanchez" <guillerm...@codetel.com.do> wrote in message
news:3f57a368$1...@newsgroups.borland.com...
> After some research, I wasn't able to find something that tells me how to
> handle the Screen Resolution Changes when running a Delphi apps.
Probably because it's difficult, as Senthil's notes confirm, and nobody is
sure they have found a way worth publishing.
> If the PC where the apps runs have 800x600 and the apps was develop using
> 1024x768 the apps doesn't look good in screen.
What exactly looks bad about them?
Do other author's apps look just as bad to you?
My apps look 'small' in high-res, on my computer, but then I would not use
high-res on *that* computer except for testing. Presumably users who like
high res have a giant monitor to go with it, so the proggie looks normal
sized... and people who like this kind of setup want to scatter various
programs around their giant screen and would not be too happy about your
program deciding to take over the entire screen area and populate it with
gigantic controls.
> Is there any way to handle this, to make the apps to resize all objects
> depending on the Screen Resolution of the PC where the apps run.
What I'm saying is : are you sure it needs doing. Remember the purpose of
your program is for your users' satisfaction, not your own.
>
> You can also use
> the Scaled property in the forms. This will correctly scale for 120/96ppi
> problem
Don't know about 'correctly'. %-(.
I found that it gave different effects according to whether the font of the
form was ANSI_CHARSET or DEFAULT_CHARSET. Very disconcerting especially as
with one of these I needed to scale run-time created components by 120/96
and with the other, not.
DEFAULT_CHARSET, which oddly enough is not the default (!), gives the form
that is actually scaled up in Large Fonts, which is presumably what someone
who chose this setting wants.
Here is the function that I use. It returns an integer representing the
actual percentage if the form is scaled at all. It will return 100 if the
form does not need to be scaled. Pass it the form reference and the original
design screen width. It will calculate everything else it needs and also
adjusts any column widths of the standard grid types.
HTH
--
Woody (TMW)
Freeware Page: http://users.eonet.net/woodytmw
function ScaleTheForm(f: TForm; OrigSize: integer): integer;
var
x,y: integer;
begin
if (Screen.Width = OrigSize) then
result := 100
else begin
result := Round(((Screen.Width-OrigSize)/OrigSize)*80)+100;
f.AutoScroll := false;
f.ScaleBy(result, 100);
for y := 0 to f.ComponentCount-1 do begin
if (f.Components[y] is TListView) and
(TListView(f.Components[y]).Columns.Count > 0) then begin
for x := 0 to TListView(f.Components[y]).Columns.Count-1 do
TListView(f.Components[y]).Columns[x].Width :=
Round(TListView(f.Components[y]).Columns[x].Width * (result
/ 100));
end else if (f.Components[y] is TStringGrid) then begin
TStringGrid(f.Components[y]).DefaultColWidth :=
Round(TStringGrid(f.Components[y]).DefaultColWidth * (result /
100));
TStringGrid(f.Components[y]).DefaultRowHeight :=
Round(TStringGrid(f.Components[y]).DefaultRowHeight * (result
/ 100));
end else if (f.Components[y] is TDBGrid) and
(TDBGrid(f.Components[y]).Columns.Count > 0) then begin
for x := 0 to TDBGrid(f.Components[y]).Columns.Count-1 do
TDBGrid(f.Components[y]).Columns[x].Width :=
Round(TDBGrid(f.Components[y]).Columns[x].Width * (result /
100));
end;
end;
end;
end;