Link to home
Start Free TrialLog in
Avatar of Tom Knowlton
Tom KnowltonFlag for United States of America

asked on

"Scaling" my applications

Something I haven't given much thought until now:

I recently wrote an application while using a high screen resolution (1024 x 768).  I sent the same application to a friend of mine, who was running in 640 x 480.  You can guess what happened:  The program was HUGE on his machine!

I need some advice on how best to handle this nuance of windows application programming.  I've tried programming all my applications in 640 x 480, knowing that they'll work in higher resolutions, but this not the resolution of choice for me when doing development work, and also not the best way to solve this problem, I'm guessing.

I messed-around with "scaling" the apps[right-click on a button component on the form, for example, and choose "Scale"] but I'm not sure if I'm doing it properly.  Do you just scale the form, or do you scale everything?  How much do you scale by?
Avatar of Epsylon
Epsylon

Everything but font sizes are scaled. And everything that inherit its size to a font doesn't scale to.

use form1.ScaleBy(75,100) scales to 75%

Use it with care!!!

Regards,

Epsylon
A better idea is not to use large forms but use a pagecontrol (TAB's) to group some stuff.
ASKER CERTIFIED SOLUTION
Avatar of viktornet
viktornet
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
btw, replace the following two lines

if Owner is TForm then
     with TForm(Owner) do begin
....

with this one...

with GetParentForm(self) do begin
....

This should wok just fine...

..-=ViKtOr=-..
HI knowlton,

Here is the simple solution (but it greats): All you need just to set the scale property from main form to TRUE and then add this to the oncreate event of the form, maybe like this:
procedure Tform1.Create()
begin
 PixelsPerInch := Getdevicecaps(handle, LOGPIXELSY);
 { your code...if any}
end;

may this help you

Avatar of Tom Knowlton

ASKER

I'm looking for solutions that do not rely on components.  Did I misunderstand your answer, Viktor?
Just place the component on the form and that will do it...

if you don't want a component simply extract the pieces of code and place them in the appropriate events of the form, but this way you will have to place the same code over and over... a component is just easier to deal with..

..-=ViKtOr=-..
I see your point.

Now, when I think of component, I think of something I click on the component palette.  How does the code you pasted into E-E translate into a working component.

Please -- forgive my ignorance.  I obviously still have a lot to learn.
first, copy the above code and save it as a PAS file somewhere on your HD>..
then go to Components->INstall Component from the Delphi IDE, (the menu that is) and then click browse on the top button, and find the PAS file that you just created... then click OK or Open or whatever the button's caption is... then, click OK, and it will ask you something... click OK.... then it should be installed in your SAMPLE Palette.. go find it, drop it on your form, and you're ready to go... no need to do anything, just keep it in the form ;)

btw, in the above unit you will see too constants, Width and Height set to certain values... make sure that those values are the resolution of your monitor, where  you're compiling your app...

..-=ViKtOr=-..
Viktor:

It may be a day or two before I have time to try this out.

If you're confident this works, I can give you your points now.

What do you think?
You better test it first and then award me the points if you think it's what you've been looking for.. if not just reject...  :)

..-=ViKtOr=-..
Did it work?
Viktor:

Didn't have a chance to try it out yet.

I will let you know if it works.

You got your points, right?
Yeah but I wanted you to try it out first...
I have faith in your abilities.  I really have no idea when I'll have time to try this out (this is a minor project, and just for fun).

If it DOESN'T work, I know where to find you.  :)

Tom
hehe, okay :)) No problem!

If there are any problems please e-mail me at viktor@megsinet.net ;)

..-=ViKtOr=-..
Okay!