FormatCode Code Formatter is based on serveral powerful syntax parser engines
so you can exactly control the appearance of your source code. Here is the code formatting demo of
FormatCode Delphi Code Formatter to prove the ability of code formatting
functions of FormatCode:
unit AutoScale;interface uses Windows,Controls,Forms,Classes,Dialogs;type
TAutoScale=class(TComponent)privateMatrix:Variant;PW,PH,BCount:Integer;procedure
GetFormInfo(Form:TForm);public constructor Create(AOwner:TComponent);override;
procedure Init(Form:TForm);procedure Resize(Form:TForm);published end;var
AutoScale1:TAutoScale;procedure Register;implementation
procedure Register;begin RegisterComponents('Uwis',[TAutoScale]);end;
constructor TAutoScale.Create(AOwner:TComponent);begin inherited; if(AOwner is TForm)then Init(AOwner as TForm)else
ShowMessage('The owner of TAutoScale is NOT a TForm.');end;
procedure TAutoScale.Init(Form:TForm);begin BCount:=Form.ControlCount-1;
Matrix:=VarArrayCreate([0,BCount,0,3], VarInteger);GetFormInfo(Form);end;
procedure TAutoScale.GetFormInfo(Form:TForm); var I:Integer;RGN:TRect;begin
for I:=0 to BCount do begin RGN:=Form.Controls[I].BoundsRect;Matrix[I,0]:=RGN.
Left;Matrix[I,1]:=RGN.Top;Matrix[I,2]:=RGN.Right;Matrix[I,3]:=RGN.Bottom;end;PW
:=Form.ClientWidth;PH:=Form.ClientHeight;end;procedure TAutoScale.Resize(Form:
TForm);var L,T,LL,TT,RR,BB,W,H,WW,HH,I:Integer;Fas:Boolean;begin WW:=Form.
ClientWidth;HH:=Form.ClientHeight;Fas:=Form.AutoScroll;Form.AutoScroll:=False;
for I:=0 to(Form.ControlCount-1)do begin LL:=((Matrix[I,0]*WW)div PW);TT:=((
Matrix[I,1]*HH)div PH);RR:=((Matrix[I,2]*WW)div PW);BB:=((Matrix[I,3]*HH)div PH)
;L:=LL;T:=TT;W:=RR-LL;H:=BB-TT;SetBounds(Form.Controls[I]);end;end;end.
unit AutoScale;
interface
uses Windows, Controls, Forms, Classes, Dialogs;
type
TAutoScale = class(TComponent)
privateMatrix: Variant;
PW, PH, BCount: Integer;
procedure GetFormInfo(Form: TForm);
public
constructor Create(AOwner: TComponent); override;
procedure Init(Form: TForm);
procedure Resize(Form: TForm);
published
end;
var
AutoScale1: TAutoScale;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Uwis', [TAutoScale]);
end;
constructor TAutoScale.Create(AOwner: TComponent);
begin
inherited; if (AOwner is TForm) then
Init(AOwner as TForm)
else
ShowMessage('The owner of TAutoScale is NOT a TForm.');
end;
procedure TAutoScale.Init(Form: TForm);
begin
BCount := Form.ControlCount - 1;
Matrix := VarArrayCreate([0, BCount, 0, 3], VarInteger);
GetFormInfo(Form);
end;
procedure TAutoScale.GetFormInfo(Form: TForm);
var
I: Integer;
RGN: TRect;
begin
for I := 0 to BCount do
begin
RGN := Form.Controls[I].BoundsRect;
Matrix[I, 0] := RGN.Left;
Matrix[I, 1] := RGN.Top;
Matrix[I, 2] := RGN.Right;
Matrix[I, 3] := RGN.Bottom;
end;
PW := Form.ClientWidth;
PH := Form.ClientHeight;
end;
procedure TAutoScale.Resize(Form: TForm);
var
L, T, LL, TT, RR, BB, W, H, WW, HH, I: Integer;
Fas: Boolean;
begin
WW := Form.ClientWidth;
HH := Form.ClientHeight;
Fas := Form.AutoScroll;
Form.AutoScroll := false;
for I := 0 to (Form.ControlCount - 1) do
begin
LL := ((Matrix[I, 0] * WW) div PW);
TT := ((Matrix[I, 1] * HH) div PH);
RR := ((Matrix[I, 2] * WW) div PW);
BB := ((Matrix[I, 3] * HH) div PH);
L := LL;
T := TT;
W := RR - LL;
H := BB - TT;
SetBounds(Form.Controls[I]);
end;
end;
end.
Click here to preview the Delphi Code Formatting Demo 1.
With FormatCode Delphi Code Formatters, you can format and transform any foreign Delphi source code to meet your preferred coding style or any common code convention in several seconds!
|