Display Settings

Posted on 2006-05-21
Medium Priority
Last Modified: 2010-04-05
Hi All

How can I change my program dimensions in accordance to the display settings.
For example if i did my program on 800*600 and later on i install it on 1152*864.


Question by:ibrobar
LVL 17

Expert Comment

ID: 16728400
Use Screen.Width and height and change Your forms sizes accordingly.
Play with Align and Anchor properties of controls

Expert Comment

ID: 16728863
Well you could write a refresh/detect screen size

procedure getsize(sender : TObject);

procedure TForm1.getsize(sender : TObject);
scry := screen.height;
scrx := screen.width;

  if scry = 640 then
    if scryx = 480 then
    //set your forms size correctly here

  if scry = 800 then
    if scryx = 600 then
    //set your forms size correctly here

  if scry = 1024 then
    if scryx = 768 then
    //set your forms size correctly here


Or you could use the good suggestion that Mokule made "Align and Anchor properties of controls"

Peace Scay7
LVL 17

Accepted Solution

TheRealLoki earned 500 total points
ID: 16730381
All you need to do is in your FormCreate() event, put
Form1.ScaleBy(Screen.Width, 1024);  // e.g. if you design in 1024x768, but a client may run in 800x600 or 640x400

From the delphi help:
Rescales a windowed control and any of its children to a percentage of their former size.

procedure ScaleBy(M, D: Integer);


Call ScaleBy to rescale the control and all its children. ScaleBy modifies the Height and Width properties of the controls, but it does not change the Top and Left properties; therefore, the size of the controls changes, but not the coordinates of the top-left corners of the controls.

The M and D parameters determine the percentage by which the control and its children are scaled. The M parameter is the multiplier and the D parameter is the divisor. For example, to change a control to be 75% of its original size, specify the value of M as 75, and the value of D as 100 (75/100). Alternately, obtain the same results by specifying the value of M as 3, and the value of D as 4 (3/4). Both fractions are equal and result in the control being scaled by the same amount, 75%.

To make the control 33% larger than its previous size, specify the value of M as 133, and the value of D as 100 (133/100). Alternately, specify the value of M as 4, and the value of D as 3 (4/3), as the fraction 133/100 is approximately equal to 4/3.

Note:      Because control sizes and coordinates are integers, scaling them by the M/D ratio incurs some degree of roundoff error. Calling ScaleBy repeatedly may mean that at some point the control disappears (when the roundoff errors make the control smaller). When rescaling controls repeatedly, consider destroying and reloading the form after several rescalings so that the coordinates are rescaled without most of the accumulating roundoff error.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 16769073
Hi it didn't work with me have you tried before

LVL 17

Expert Comment

ID: 16772423
yes, I use it a lot.
It might be your form's position.
Try setting it to fpDefaultPosOnly

Author Comment

ID: 16804768
Thanks a lot RealLoki , you are great


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

840 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