[Webinar] Streamline your web hosting managementRegister Today


How 2 auto change Form's screen size 2 users setup or change users screen to suit forms size

Posted on 2000-02-21
Medium Priority
Last Modified: 2010-04-04
How 2 auto change Form's screen size 2 users setup or change users screen to suit forms size. eg: form is set to 1024*768 this shows complete view
but some users can only have 800*600 or 640*480
when displayed on smaller size the scroll bar's show's
the form's lose there apearance

Thanks Brian
Question by:pied
  • 2
  • 2
LVL 17

Accepted Solution

inthe earned 800 total points
ID: 2543673
i ahve a couple of examples i think should help:
Regards Barry

example 1:

procedure AdjustResolution(oForm:TForm);
if Screen.Width > 640 then

//call it like so

example 2:

This demonstrate how to scale your form and all components
 so its always
appear in the same size regardles of the users screen

  // The Screen with and height you designed form in
  ScreenHeight: integer = 800;
  ScreenWidth: integer = 600;

procedure TForm1.FormCreate(Sender: TObject);
  x, y: LongInt;
  Form1.scaled := true;
  x := getSystemMetrics(SM_CXSCREEN);
  y := getSystemMetrics(SM_CYSCREEN);
  if (x <> ScreenHeight) or (y <> ScreenWidth) then
    Form1.height := Form1.height * x DIV ScreenHeight;
    Form1.width := Form1.width * y DIV ScreenWidth;
    scaleBy(x, ScreenHeight);

Expert Comment

ID: 2543681
One thing you might want to do is to set the form's SCALED property to true. Next, if you are developing an app that might be displayed on several different screen resolutions, you might consider using  calculated dimnesions for your form's and controls. For Example:

Form1.height:=Screen.height div 2;
Form1.width:=Screen.width div 2;
Button1.height:=Round(Form1.height *0.1);
Button1.width:=Round(Form1.width * 0.1);

Etc, etc, etc....

this should help.

Good luck!!


Author Comment

ID: 2563220
Thanks Barry & DrDelphi
the form & bottons work great
is there a way to get the text to fit the edit box's

thanks again

Author Comment

ID: 2563229
Thanks Barry & DrDelphi
the form & bottons work great
is there a way to get the text to fit the edit box's

thanks again
LVL 17

Expert Comment

ID: 2563337
This is from a Borland FAQ about scaling:

A: The following are issue to bear in mind when scaling Delphi
  applications (forms) on different screen resolutions?
  * Decide early on in the form design stage whether you're going to     allow the form to be scaled or not.  The advantage of not scaling is     that nothing changes at runtime.  The disadvantage of not scaling is     that nothing changes at runtime (your form may be far too small or     too large to read on some systems if it is not scaled).
  * If you're NOT going to scale the form, set Scaled to False.
  * Otherwise, set the Form's Scaled property to True.
  * Set AutoScroll to False.  AutoScroll = True means 'don't change the     form's frame size at runtime' which doesn't look good when the     form's contents do change size.
  * Set the form's font to a scaleable TrueType font, like Arial.     MS San Serif is an ok alternate, but remember that it is still a     bitmapped font.  Only Arial will give you a font within a pixel of     the desired height.  NOTE: If the font used in an application is not     installed on the target computer, then Windows will select an     alternative font within the same font family to use instead.     This font may not match the same size of the original font any may     cause problems.
  * Set the form's Position property to something other than poDesigned.     poDesigned leaves the form where you left it at design time, which     for me always winds up way off to the left on my 1280x1024 screen -     and completely off the 640x480 screen.
  * Don't crowd controls on the form - leave at least 4 pixels between     controls, so that a one pixel change in border locations (due to     scaling) won't show up as ugly overlapping controls.
  * For single line labels that are alLeft or alRight aligned, set     AutoSize to True.  Otherwise, set AutoSize to False.
  * Make sure there is enough blank space in a label component to allow     for font width changes - a blank space that is 25% of the length of     the current string display length is a little too much, but safe.     (You'll need at least 30% expansion space for string labels if you     plan to translate your app into other languages) If AutoSize is     False, make sure you actually set the label width appropriately.     If AutoSize is True, make sure there is enough room for the label     to grow on its own.
  * In multi-line, word-wrapped labels, leave at least one line of     blank space at the bottom.  You'll need this to catch the overflow     when the text wraps differently when the font width changes with     scaling. Don't assume that because you're using large fonts, you     don't have to allow for text overflow - somebody else's large     fonts may be larger than yours!
  * Be careful about opening a project in the IDE at different
    resolutions.  The form's PixelsPerInch property will be modified     as soon as the form is opened, and will be saved to the DFM if     you save the project. It's best to test the app by running it     standalone, and edit the form at only one resolution. Editing     at varying resolutions and font sizes invites component drift     and sizing problems.
  * Speaking of component drift, don't rescale a form multiple times,     at design time or a runtime.  Each rescaling introduces roundoff     errors which accumulate very quickly since coordinates are
    strictly integral.  As fractional amounts are truncated off
    control's origins and sizes with each successive rescaling,
    the controls will appear to creep northwest and get smaller.     If you want to allow your users to rescale the form any number     of times, start with a freshly loaded/created form before each     scaling, so that scaling errors do not accumulate.
  * Don't change the PixelsPerInch property of the form, period.
  * In general, it is not necessary to design forms at any particular     resolution, but it is crucial that you review their appearance at     640x480 with small fonts and large, and at a high-resolution with     small fonts and large before releasing your app.  This should be     part of your regular system compatibility testing checklist.
  * Pay close attention to any components that are essentially
    single-line TMemos - things like TDBLookupCombo.  The Windows     multi-line edit control always shows only whole lines of text -     if the control is too short for its font, a TMemo will show
    nothing at all (a TEdit will show clipped text). For such
    components, it's better to make them a few pixels too large than     to be one pixel too small and show not text at all.
  * Keep in mind that all scaling is proportional to the difference     in the font height between runtime and design time, NOT the pixel     resolution or screen size.  Remember also that the origins of your     controls will be changed when the form is scaled - you can't very     well make components bigger without also moving them over a bit.

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…
Suggested Courses

611 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