Board index » delphi » Screen size changes

Screen size changes

The apps that I'm working on are being developed on a system with
1024x768 17' monitor; however, the end-users are of various other
resolutions (primarily 800x600 14').  No matter how I design the various
forms for my apps, they get terribly screwed up when running on a smaller
screen.  For example, huge gaps appear in panels and the right margin
tends to move right of where I designed it.  I need to make sure that
what I see is what the end-user sees.  Any help is appreciated.

Mark

Please reply via e-mail (and also here?)

 

Re:Screen size changes


"Mark E. Johnson" <mjohn...@ficodc.com> wrote:

Quote
>The apps that I'm working on are being developed on a system with
>1024x768 17' monitor; however, the end-users are of various other
>resolutions (primarily 800x600 14').  No matter how I design the various
>forms for my apps, they get terribly screwed up when running on a smaller
>screen.  For example, huge gaps appear in panels and the right margin
>tends to move right of where I designed it.  I need to make sure that
>what I see is what the end-user sees.  Any help is appreciated.
>Mark
>Please reply via e-mail (and also here?)

In the OnShow event for the form, insert the followinf line
ChangeScale(800, 1024);

This will rescale your form correctly.

Re:Screen size changes


Quote
Mark E. Johnson wrote:

> The apps that I'm working on are being developed on a system with
> 1024x768 17' monitor; however, the end-users are of various other
> resolutions (primarily 800x600 14').  No matter how I design the various
> forms for my apps, they get terribly screwed up when running on a smaller
> screen.  For example, huge gaps appear in panels and the right margin
> tends to move right of where I designed it.  I need to make sure that
> what I see is what the end-user sees.  Any help is appreciated.

> Mark

> Please reply via e-mail (and also here?)

I don't claim that this is the most efficient way, but it works..

Here is the stuff I put in the OnCreate method for the form.  In this case, it is a modal dlg used for
taking user inputs.  I want the form to appear in the middle of the screen.

I am developing at 800x600 with small fonts.

Note that MainHeight and MainWidth are the size of the maximized main application form.  These detect
whether things like the Win95 tool bar and Office tool bar are there.  For this to work, I start my
application maximized, although I'm sure there are plenty of ways around it.  So, this form needs to be
able to see MainWidth/Height - I do it with a little unit that both the Main form and this dlg can see.

procedure TModPrmsDlg.FormCreate(Sender: TObject);
var s : string;
    i,
    wDesign, hDesign : integer;
    wsf, hsf : single;
    st : string;
begin
  // deal with resolution... much stuffing around...
  wDesign := 680;  //  The size of the form at design time
  hDesign := 500;
  wsf := 1;
  hsf := 1;
  if PixelsPerInch > 100 then  // deal with small or large fonts
  begin
    wsf :=  PixelsPerInch / 96;
    hsf := wsf * ( screen.height/600 ) / (screen.width/800);
  end;
  if ( hDesign * hsf < MainHeight ) then
    height := round( hDesign * hsf )
  else
  begin
    height := MainHeight;
    hsf := height / ( hDesign * hsf );
    for i := 0 to ComponentCount - 1 do
      if ( Components[i] is TControl ) then     // need this to avoid things like TPopupMenu
      begin
        (Components[i] as TControl).height := round( hsf * (Components[i] as TControl).height );
        (Components[i] as TControl).top  := round( hsf * (Components[i] as TControl).top );
      end;
  end;

  if ( wDesign * wsf < MainWidth ) then
    width := round( wDesign * wsf )
  else
  begin
    width := MainWidth;
    wsf := width / ( wDesign * wsf );  // ratio of what it wanted to be to what it can be...
    for i := 0 to ComponentCount - 1 do
      if ( Components[i] is TControl ) then     // need this to avoid TPopupMenu
      begin
        (Components[i] as TControl).width  := round( wsf * (Components[i] as TControl).width );
        (Components[i] as TControl).left := round( wsf * (Components[i] as TControl).left );
      end;
  end;

  // now set position
  top := MainTop + ( MainHeight - height ) div 2;
  left := MainLeft + ( MainWidth - width ) div 2;

  // it seems that Tlabel does not rescale properly at 640x480
  for i := 0 to ComponentCount - 1 do
  begin
    if ( ( Screen.width < 800 ) and ( Components[i] is TLabel ) ) then
    begin
      (Components[i] as TLabel).width  := round( (Components[i] as TLabel).width * 1.25 );
      (Components[i] as TLabel).height  := round( (Components[i] as TLabel).height * 1.25 );
    end;
  end;

etc...

Good luck!

If you make any improvements on this, please let me know.

Ian

--
----------------------------------------------------------------
Dr Ian Johnson
IMJ Consultants

ph/fax:  Within Australia:       067 712133
         Outside Australia: (+61) 67 712133
email:   green...@northnet.com.au
----------------------------------------------------------------

Re:Screen size changes


Quote
>Mark E. Johnson wrote:

>> The apps that I'm working on are being developed on a system with
>> 1024x768 17' monitor; however, the end-users are of various other
>> resolutions (primarily 800x600 14').  No matter how I design the various
>> forms for my apps, they get terribly screwed up when running on a smaller
>> screen.  For example, huge gaps appear in panels and the right margin
>> tends to move right of where I designed it.  I need to make sure that
>> what I see is what the end-user sees.  Any help is appreciated.

Get hold of Borland's tech note TI2861 - title 'Form display with
different screen resolutions', available for Borland's site and the
Delphi Super Page in the bor directory.

Pat
--
Pat White               If we had Delphi for DOS we wouldn't need Windows
email: p...@pwhite.demon.co.uk
Phone; 44+(0)1925 266113

Other Threads