Thanks Kell_pt.
I've added the code and sent it on to see how it looks on his monitor. I'll let you know something as soon as tomorrow I think.
reddarin
Main Topics
Browse All TopicsI am writing a small utility program for a business associate.
I have a nice LCD monitor (17 inch) at 1280x1024. He has a crappy something or other running at 800x600.
I would like the code to make my program screen resolution independent. I'd settle for a component that you'll stand by as excellent but I am very tight on cash right now and I can't afford jack. If it will run without the IDE running, nag message or not, then that may be acceptable.
I don't need an entire application written for me, just as many lines of code as it takes to show me the way. Additionally, is it sufficient to use a true type font and leave it at that or will the font need to be resized along with any given component?
I got lots of points so name your price if 500 is insufficient.
reddarin
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi,
Try this one:
const
// The Screen width and height you designed the form with
ScreenHeight: integer = 1280;
ScreenWidth: integer = 1024;
procedure TForm1.FormCreate(Sender: TObject);
var
x, y: LongInt;
begin
Form1.scaled := true;
x := getSystemMetrics(SM_CXSCRE
y := getSystemMetrics(SM_CYSCRE
if (x <> ScreenHeight) or (y <> ScreenWidth) then
begin
Form1.height := Form1.height * x DIV ScreenHeight;
Form1.width := Form1.width * y DIV ScreenWidth;
scaleBy(x, ScreenHeight);
end;
end;
Regards, Geo
Hi guys,
So far, no solution has worked really well on the clients computer.
geobul - When I use your snippet, the tab text disspears. I am using TOVCNotebook. I haven't tried it with a regular page control or notebook control.
My time is really limited but I am going to set up a test computer running on a regular monitor (CRT) at 800x600 and test each suggestion myself. I should be able to get that done by Tuesday this coming week (July 8th). If it looks right on my test computer then I'm gonna consider it a done deal and I'll let that guy know that his computer is AFU.
Sorry for the delay.
reddarin
Hi again guys,
Sorry for taking so long to get back to this question.
Thanks for your input Kell_pt and Geo. Neither solution seemed to work for me between the two monitors. There was some problem with fonts and with the tabs on the page control I was using.
I created a new app and ran it on a computer at work and andrewjb's comment/advice seems to be the most applicable for what I'm doing.
Thanks for the help!
reddarin
Business Accounts
Answer for Membership
by: Kell_ptPosted on 2003-06-30 at 19:45:48ID: 8831897
A simple solution, w/o having to get any extra software, is to resize the controls when the form is created, taking in consideration the resolution the form was designed for.
All you have to do is call the function below in FormCreate, and pass as parameters the resolution you designed the form to be shown at. That's an important argument, because it'll allow the code to scale the controls accordingly. It'll then fetch the resolution the form is running at, and scale. Here's how you'd call it:
procedure TForm1.FormCreate(Sender: TObject);
begin
FormResolutionAdjust( self, 1024, 768 );
end;
And the function that does the trick:
Procedure FormResolutionAdjust( frm: TForm; design_w, design_h: Integer);
var
i : Integer;
rw, rh : Real; // ratios
begin
// calculate ratios from design resolution
rw := Screen.Width / design_w;
rh := Screen.Height / design_h;
for i := 0 to frm.ControlCount - 1 do begin
With TLabel(frm.Controls[i]) do begin
// resize and move
width := Round(width * rw);
height := Round(height * rh);
left := Round(left * rw);
top := Round(top * rw);
// resize font
try Font.Size := Round(Font.size * rw); finally; end;
end;
end;
// resize the form
frm.Width := Round(frm.width * rw);
frm.height := Round(frm.height * rh);
end;
You'll notice a cheap trick of reading every control as a TLabel. That's because although TControl DOES have a Font object, it only gets implemented upwards in the control hierarchy. The "Try... finally" code is just to prevent the odd case in which a control doesn't have an allocated TFont object. I tried with about 20 different controls on a form, and it scale beautifylly. :)
This even works if at some point in time you decide you want to make your form smaller and are unwilling to change the design.
Try it out. If this doesn't fully work for you, I'm sure it can be sorted out.
Cheers.