Board index » delphi » auto resize forms by other screen resoloution

auto resize forms by other screen resoloution

hello,

I have created a form by a screen resolution 800 x 600,
but when i view the form on a screen resolution 640 x 480
the form is greater then my screen, now i found a solution for that
see source code bellow, but some components in the form won't resize,
for exemple the radiobuttons, does someone have a idea how i can solve
that problem.

implementation
const
  ScreenWidth: LongInt = 800; {I designed my form in 800x600 mode.}
  ScreenHeight: LongInt = 600;

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var  i, OldFormWidth: integer;
begin
    scaled := true;
    if (screen.width  ScreenWidth) then
    begin
        OldFormWidth := width;
        height := longint(height) * longint(screen.height) DIV
ScreenHeight;
        width := longint(width) * longint(screen.width) DIV ScreenWidth;
        scaleBy(screen.width, ScreenWidth);
        font.size := (Width DIV OldFormWidth) * font.size;
    end;
end;

regards, mario

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet

 

Re:auto resize forms by other screen resoloution


Quote
mario.vandewa...@ping.be wrote in message <880815380.12...@dejanews.com>...
>hello,

>I have created a form by a screen resolution 800 x 600,
>but when i view the form on a screen resolution 640 x 480
>the form is greater then my screen, now i found a solution for that
>see source code bellow, but some components in the form won't resize,
>for exemple the radiobuttons, does someone have a idea how i can solve
>that problem.

>implementation
>const
>  ScreenWidth: LongInt = 800; {I designed my form in 800x600 mode.}
>  ScreenHeight: LongInt = 600;

>{$R *.DFM}

>procedure TForm1.FormCreate(Sender: TObject);
>var  i, OldFormWidth: integer;
>begin
>    scaled := true;
>    if (screen.width  ScreenWidth) then
>    begin
>        OldFormWidth := width;
>        height := longint(height) * longint(screen.height) DIV
>ScreenHeight;
>        width := longint(width) * longint(screen.width) DIV ScreenWidth;
>        scaleBy(screen.width, ScreenWidth);
>        font.size := (Width DIV OldFormWidth) * font.size;
>    end;
>end;

Perhaps you should try with the Form's OnResize Event, resizing there your
buttons proportionally, with the form,

for example:

proc TForm1.FormResize;
begin
        Button1.Width := Form1.Width div 13;
        Button1.Height := Form1.Height div 11;
end;

you will probably have to change the position of the buttons on the form, as
the form is resized....

Button1.Left := Form1.Width - Button1.Width - 10;     for example and the
same thing wiht Button1.Top

I hope I helped a little....

Re:auto resize forms by other screen resoloution


Quote
Hrvoje Ptiar wrote:

> mario.vandewa...@ping.be wrote in message <880815380.12...@dejanews.com>...
> >hello,

> >I have created a form by a screen resolution 800 x 600,
> >but when i view the form on a screen resolution 640 x 480
> >the form is greater then my screen, now i found a solution for that
> >see source code bellow, but some components in the form won't resize,
> >for exemple the radiobuttons, does someone have a idea how i can solve
> >that problem.

Hiya,

After a lot of testing and checking sources, I've found the following
works really well:

Resize that works :
--------------------
1. Set all your forms' "Scaled" property to TRUE.

2. For all the components and the forms, use a TrueType font like
Arial, and set its "Pitch" property to 'fpVariable' (an easy way to do
this is to set your components' use parent font property to true!)

3. Make sure that the form you design is within the displayable limits
   of your screen and use a 1.33 design ratio (e.g witdh = height *  
1.33) - this is important otherwise you'll find that you end-up with
dead space when changing resolution!

4. Set the main form's "Position" property to 'poScreenCenter'.

Regards,

Rudi

Other Threads