Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

"Scaling" my applications

Posted on 1999-07-25
17
Medium Priority
?
245 Views
Last Modified: 2013-11-22
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?
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
  • 2
  • +1
17 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 1391086
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
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1391087
A better idea is not to use large forms but use a pagecontrol (TAB's) to group some stuff.
0
 
LVL 10

Accepted Solution

by:
viktornet earned 200 total points
ID: 1391088
Hello Tom!

Here is a component I wrote once for a use on E-E (venks I think was the guy :)), and it's not really complete, but I think will do what you want... If you want everything to be okay, you should probably play around with it a little :)

It scales the font's and the form, as well as the controls inside the form...

================

unit Scaler;

     interface

     uses
       Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
     Dialogs;
     const
        ScreenWidth  : Integer = 800; //If you don't want to declare
constants
                                     //you'd have to have a
        ScreenHeight : Integer = 600;//property for each of these two so
you can
    // declare it at //designtime
     type
       TScaler = class(TComponent)
       private
         FAllScaled : Boolean;
       protected
         { Protected declarations }
       public
         constructor Create(AOwner : TComponent);override;
         procedure Loaded;override;
       published
         { Published declarations }
       end;
     procedure Register;
     implementation
constructor TScaler.Create(AOwner : TComponent);
begin
  Inherited Create(AOwner);
  fAllScaled := False;
end;
procedure TScaler.Loaded;
begin
  Inherited;
  if not(csDesigning in ComponentState) then
    if Owner is TForm then
    with TForm(Owner) do begin
      Font.Pitch := fpVariable;
      if (not

fAllScaled)and((Screen.Width<>ScreenWidth)or(Screen.Height<>ScreenHeight))then
       begin
         Scaled := True;
         AutoScroll := False;
          if Screen.Width < ScreenWidth then
         ScaleBy(Screen.Width, ScreenWidth)
         else ScaleBy(ScreenWidth, Screen.Width);
         fAllScaled := True;
       end;
     end;
end;
procedure Register;
begin
  RegisterComponents('System', [TScaler]);
end;
end.
=======
..-=fOoL=-..
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 10

Expert Comment

by:viktornet
ID: 1391089
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=-..
0
 
LVL 3

Expert Comment

by:Hencah
ID: 1391090
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

0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 1391091
I'm looking for solutions that do not rely on components.  Did I misunderstand your answer, Viktor?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1391092
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=-..
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 1391093
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.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1391094
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=-..
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 1391095
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?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1391096
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=-..
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1391097
Did it work?
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 1391098
Viktor:

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

I will let you know if it works.

You got your points, right?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1391099
Yeah but I wanted you to try it out first...
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 1391100
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
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1391101
hehe, okay :)) No problem!

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

..-=ViKtOr=-..
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 1391102
Okay!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question