[DUG] Screen resolution

John Bird johnkbird at paradise.net.nz
Mon Jul 16 12:44:41 NZST 2012


Yes - I do exactly that.   I advise you to make it a function that is 
standalone or a library function and call it from wherever you need this 
functionality, as I found I ended up tweaking and refining it quite a lot 
and it became more and more useful.  I would paste the code except it is 
heavily tailored to the environment I setup when a program starts...

I ended with quite a lot of error checking on making sure the scaleby 
amounts were valid, ie not overflowing the screen size, and adjusting some 
component default font sizes, eg for stringgrids.

Email me direct if you want to see some of the code, or a test program I 
write to test the approach - but you are on the right track.

Incidentally you may be better to use

screen.WorkAreaWidth and screen.WorkAreaHeight etc   as this takes out the 
space used by the task bar if applicable.


John Bird

-----Original Message----- 
From: Marshland Engineering
Sent: Sunday, July 15, 2012 8:10 PM
To: delphi at listserver.123.net.nz
Subject: Re: [DUG] Screen resolution

Is there a way to adjust all the visual componets on a form programatically
?

Then I can do something like this.

   rWidScale:=Screen.Width/fmain.Width;
   rHeiScale:=Screen.Height/fmain.Height;

   fMain.Left:=0;                                                      //
Set  the form to full screen
   fMain.Top:=0;
   fMain.Height:=Round(fMain.Height*rHeiScale);
   fMain.Width:=Round(fMain.Width*rWidScale);

   Button1.Top:=Round(Button1.Top*rHeiScale);    //Scale each visual
component
   Button1.Left:=Round(Button1.Left*rWidScale);
   Button1.Height:=Round(Button1.Height*rHeiScale);
   Button1.Width:=Round(Button1.Width*rWidScale);
   Button1.Font.Size:=Round(Button1.Font.Size*rHeiScale);

   DBGrid1.Top:=Round(dbGrid1.Top*rHeiScale);  /// etc
   DBGrid1.Left:=Round(dbGrid1.Left*rWidScale);
   DBGrid1.Height:=Round(dbGrid1.Height*rHeiScale);
   DBGrid1.Width:=Round(dbGrid1.Width*rWidScale);
   DBGrid1.Font.Size:=Round(dbGrid1.Font.Size*rHeiScale);

_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi at listserver.123.net.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-request at listserver.123.net.nz with 
Subject: unsubscribe 



More information about the Delphi mailing list