unit DemoFakultaet;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    btnDemo: TButton;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure btnDemoClick(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses
  uTraceDx;


procedure TForm1.FormCreate( Sender: TObject );
begin
  TraceDx.Call( Sender, 'FormCreate' );
end;

procedure TForm1.FormDestroy( Sender: TObject );
begin
  TraceDx.Call( Sender, 'FormDestroy' );
end;

function Fakultaet( X: integer ): integer;
begin
  TraceDx.CallRet( 'Fakultaet', X, rtInteger, Result, 'Result' );
  if X > 1
    then Result := X * Fakultaet( X-1 )
    else Result := 1
end;

procedure TForm1.btnDemoClick( Sender: TObject );
var X: integer;
begin
  TraceDx.Call( Self, 'btnDemoClick' );
  X := Fakultaet( 4 )
end;


initialization
  TraceDx.Send( 'initialization uMain');
  TraceDx.Messages.Enable( mtAppOnMessage, true ); { Application.OnMessage() }
  TraceDx.Messages.SelectShow( mtAppOnMessage, [WM_LBUTTONDOWN, WM_LBUTTONUP] )

finalization
  TraceDx.Send( 'finalization uMain');

end.
