The simplest way is just to have definition in the interface and then copy
what you have to the implementation

unit Unit1;

interface

 You'll need to use a few units to find the reference to TForm etc

procedure FormScale (rHeiScale:real; rWidScale:real; sForm:tForm);

implementation


procedure FormScale (rHeiScale:real; rWidScale:real; sForm:tForm);
var
   i:integer;
   rWidth,rHeight:real;
begin
   with sForm do begin
      rHeight:=rHeiScale*(Screen.Height/Height);   // Scale form
      rWidth:=rWidScale*(Screen.Width/Width);
      Height:=Round(Height*rHeight);
      Width:=Round(Width*rWidth);
      Left:=Round((Screen.Width-Width)/2);   // Center form
      Top:=Round((Screen.Height-Height)/2);
      for i:=0 to componentcount-1 do
        if Components[i] is TControl then begin
          TControl(Components[i]).Top :=
Round(TControl(Components[i]).Top*rHeight);
          TControl(Components[i]).Width :=
Round(TControl(Components[i]).Width*rWidth);
          TControl(Components[i]).Height :=
Round(TControl(Components[i]).Height*rHeight);
          TControl(Components[i]).Left :=
Round(TControl(Components[i]).Left*rWidth);
       end;
   end;
end;

end.

A slightly different way would be to make a class, then have a class
function in the interface.
Ie:

type

TWallacesFormResize = TObject
public
   class procedure FormScale (rHeiScale:real; rWidScale:real; sForm:tForm);
end;

Then to call it for a form it's

TWallacesFormResize.FormScale(parameters)



On Wed, Oct 12, 2016 at 11:10 AM, Marshland Engineering <
marshl...@marshland.co.nz> wrote:

> When I put it in the interface unit, it added a uses statement before it
> with
> the forms included in it and each time I compiled it added more and more
> bits
> in.
>
> >Why not just put it in it's own unit (or a common utilities unit) and
> include
> it in any form that needs it, rather than having it in the mainform
> unit
>
> I like this idea but not sure how to implement it and how to call it.
>
> Adding a blank unit, I have
>
> unit Unit1;
>
> interface
>
> implementation
>
> end.
>
> Thanks Wallace.
>
>
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi@listserver.123.net.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-requ...@listserver.123.net.nz with
> Subject: unsubscribe
>
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@listserver.123.net.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@listserver.123.net.nz with 
Subject: unsubscribe

Reply via email to