Delphi Pages Forums

Delphi Pages Forums (
-   General (
-   -   Form Resolution independent (

delphimpd 02-07-2012 10:17 PM

Form Resolution independent
Hi All and thanks for your help.

I was wondering if you guys can help me out on this code.

I used to program my Applications in Delphi 7 however a while back I updagraded to 2010. I own a copy of ElasticForm which is in charge of handeling all type of Screen resolution changes, however, ElasticForm is not compatible with 2010. I tried to contact the Component developer but no answer from her.

I found this code out there, which is suposed to take care of resolution changes and make all components inside the form resolution independant, however it is not working for me, I am sure that I am not doing things right.

Perhaps you have a better solution, or a better explanation of how to use the below code the right way.

Thanks again for your help.

Here is the code


procedure ScaleForm(F: TForm; ScreenWidth, ScreenHeight: LongInt) ;
  F.Scaled := True;
  F.AutoScroll := False;
  F.Position := poScreenCenter;
  F.Font.Name := 'Arial';
  if (Screen.Width <> ScreenWidth) then begin
    F.Height :=
        LongInt(F.Height) * LongInt(Screen.Height)
        div ScreenHeight;
    F.Width :=
        LongInt(F.Width) * LongInt(Screen.Width)
        div ScreenWidth;
    F.ScaleBy(Screen.Width,ScreenWidth) ;

Marsheng 07-03-2012 01:13 PM

I've tried fMain.scaleby(120,120);
But nothing happens. Tried a button, panel but non change size. Is there something i need to activate? Scaled is set to true. Delphi 6

delphimpd 07-06-2012 03:27 PM

Hi Sorry, never worked for me neither.


jm78 07-11-2012 07:57 AM


Originally Posted by Marsheng (Post 222637)
I've tried fMain.scaleby(120,120);
But nothing happens.

Not sure what is expected to happen?

Anyway, few years ago I started getting feedback about problems with some resolutions. Not all components would fit into window. I added this line to every formcreate and I haven't had problems since. (D7/D2006)

if pixelsperinch>120 then scaleby(120,120);

Marsheng 07-12-2012 12:28 AM

After trying heaps of options with ScaleBy and nothing happening, I finally found a tutorial on the web which showed my the error .


You would think that M and D would be height and width, but no, M is new and D is original. If you want to scale something by 20% you enter ScaleBy(120,100) or ScaleBy(60,50) or (30,25) Make sense. Unless you are smoking the same weed as the Delphi developers are, it won't. Now read the help ? Any better - No.

If some one is not intelligent enough to program ScaleBy(Round(NewSize/OldSize)) then they should be banned from using Delphi.

Saying all that, ScaleBy only does panels and other static bits. It does not do DBGrids. For that you really have no option left other than recoding each page with each grid for each screen resolution.

You would thinks that a 10 + year old and very expensive developmemnt package would cater for different resolutions but no.

It Sucks.

I've tried 3 third party scaling packages and all have issues.


Marsheng 07-14-2012 09:58 AM

Hopefully I'm not on the wrong path but this works well enough.

Is there a way to take all visible elements on a form and apply a scaling factor programatically instead of one by one as below?


procedure TfMain.Button1Click(Sender: TObject);
  rWidScale:=Screen.Width/fMain.Width;  // Scale to full screen
  fMain.Left:=0;  // Full screen

All times are GMT. The time now is 10:19 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2018, vBulletin Solutions, Inc.