<div dir="ltr">The simplest way is just to have definition in the interface and then copy what you have to the implementation<div><br></div><div>unit Unit1;<br></div><div><br>interface<br><br> You'll need to use a few units to find the reference to TForm etc<br><br><div><span style="font-size:12.8px">procedure FormScale (rHeiScale:real; rWidScale:real; sForm:tForm);</span><br></div><div><span style="font-size:12.8px"><br></span></div>implementation<br><br><br><span style="font-size:12.8px">procedure FormScale (rHeiScale:real; rWidScale:real; sForm:tForm);</span><br style="font-size:12.8px"><span style="font-size:12.8px">var</span><br style="font-size:12.8px"><span style="font-size:12.8px"> i:integer;</span><br style="font-size:12.8px"><span style="font-size:12.8px"> rWidth,rHeight:real;</span><br style="font-size:12.8px"><span style="font-size:12.8px">begin</span><br style="font-size:12.8px"><span style="font-size:12.8px"> with sForm do begin</span><br style="font-size:12.8px"><span style="font-size:12.8px"> rHeight:=rHeiScale*(Screen.</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">Height/Height); // Scale form</span><br style="font-size:12.8px"><span style="font-size:12.8px"> rWidth:=rWidScale*(Screen.</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">Width/Width);</span><br style="font-size:12.8px"><span style="font-size:12.8px"> Height:=Round(Height*rHeight);</span><br style="font-size:12.8px"><span style="font-size:12.8px"> Width:=Round(Width*rWidth);</span><br style="font-size:12.8px"><span style="font-size:12.8px"> Left:=Round((Screen.Width-</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">Width)/2); // Center form</span><br style="font-size:12.8px"><span style="font-size:12.8px"> Top:=Round((Screen.Height-</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">Height)/2);</span><br style="font-size:12.8px"><span style="font-size:12.8px"> for i:=0 to componentcount-1 do</span><br style="font-size:12.8px"><span style="font-size:12.8px"> if Components[i] is TControl then begin</span><br style="font-size:12.8px"><span style="font-size:12.8px"> TControl(Components[i]).Top :=</span><br style="font-size:12.8px"><span style="font-size:12.8px">Round(TControl(Components[i]).</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">Top*rHeight);</span><br style="font-size:12.8px"><span style="font-size:12.8px"> TControl(Components[i]).Width :=</span><br style="font-size:12.8px"><span style="font-size:12.8px">Round(TControl(Components[i]).</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">Width*rWidth);</span><br style="font-size:12.8px"><span style="font-size:12.8px"> TControl(Components[i]).Height :=</span><br style="font-size:12.8px"><span style="font-size:12.8px">Round(TControl(Components[i]).</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">Height*rHeight);</span><br style="font-size:12.8px"><span style="font-size:12.8px"> TControl(Components[i]).Left :=</span><br style="font-size:12.8px"><span style="font-size:12.8px">Round(TControl(Components[i]).</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">Left*rWidth);</span><br style="font-size:12.8px"><span style="font-size:12.8px"> end;</span><br style="font-size:12.8px"><span style="font-size:12.8px"> end;</span><br style="font-size:12.8px"><span style="font-size:12.8px">end;</span><br><br>end.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">A slightly different way would be to make a class, then have a class function in the interface.</div><div class="gmail_extra">Ie:</div><div class="gmail_extra"><br></div><div class="gmail_extra">type</div><div class="gmail_extra"><br></div><div class="gmail_extra">TWallacesFormResize = TObject</div><div class="gmail_extra">public</div><div class="gmail_extra"> class <span style="font-size:12.8px">procedure FormScale (rHeiScale:real; rWidScale:real; sForm:tForm);</span></div><div class="gmail_extra"><span style="font-size:12.8px">end;</span></div><div class="gmail_extra"><br></div><div class="gmail_extra">Then to call it for a form it's</div><div class="gmail_extra"><br></div><div class="gmail_extra">TWallacesFormResize.<span style="font-size:12.8px">FormScale(parameters)</span><br></div><div class="gmail_extra"><span style="font-size:12.8px"><br></span></div><div class="gmail_extra"><span style="font-size:12.8px"><br></span></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 12, 2016 at 11:10 AM, Marshland Engineering <span dir="ltr"><<a href="mailto:marshland@marshland.co.nz" target="_blank">marshland@marshland.co.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">When I put it in the interface unit, it added a uses statement before it with<br>
the forms included in it and each time I compiled it added more and more bits<br>
in.<br>
<span class="gmail-"><br>
>Why not just put it in it's own unit (or a common utilities unit) and include<br>
it in any form that needs it, rather than having it in the mainform<br>
unit<br>
<br>
</span>I like this idea but not sure how to implement it and how to call it.<br>
<br>
Adding a blank unit, I have<br>
<br>
unit Unit1;<br>
<br>
interface<br>
<br>
implementation<br>
<br>
end.<br>
<br>
Thanks Wallace.<br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
<br>
______________________________<wbr>_________________<br>
NZ Borland Developers Group - Delphi mailing list<br>
Post: <a href="mailto:delphi@listserver.123.net.nz">delphi@listserver.123.net.nz</a><br>
Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" rel="noreferrer" target="_blank">http://delphi.org.nz/mailman/<wbr>listinfo/delphi</a><br>
Unsubscribe: send an email to <a href="mailto:delphi-request@listserver.123.net.nz">delphi-request@listserver.123.<wbr>net.nz</a> with Subject: unsubscribe<br>
</div></div></blockquote></div><br></div></div>