Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reset a delphi TForm to original appearance after use of ScaleBy()

I want to allow a form to be sized by the user with its controls proportionaly resized. ScaleBy( N,M ) works fine for me but there are of course cumulative rounding errors if it is repeated. To counter this I simply wish to precede ScaleBy() with a call to recreate the form in its default appearance and size and then call ScaleBy with various values. I know I can do this by hosting my form within a panel (and disposing / recreating it) but is there a call that will reset the form after use of ScaleBy()?

Edit - I am using Delphi XE2 and would also be interested in anyone's success with a component or other code (paid or free) to scale a form neatly - my own downloads have not produced a working solution.

like image 315
Brian Frost Avatar asked Jan 05 '12 11:01

Brian Frost


1 Answers

Try EasySize (TFormResizer) component.
The TFormResizer component resizes all of the controls on a form (or panel) when the form size changes.
I used it successfully years ago - works with D5/7. You might need to make small adjustments for XE2 (I do not have XE2, so I cant test it).

Usage:

uses
  ..., Easysize;

type
  TForm1 = class(TForm)
    ...        
    procedure FormCreate(Sender: TObject);
    procedure FormResize(Sender: TObject);
  private
    FR: TFormResizer;
  end;

...

procedure TForm1.FormCreate(Sender: TObject);
begin
  FR := TFormResizer.Create(Self);
  FR.ResizeFonts := True;
  FR.InitializeForm;
end;

procedure TForm1.FormResize(Sender: TObject);
begin
  FR.ResizeAll;
end;

end.
like image 94
kobik Avatar answered Sep 18 '22 12:09

kobik