Smartzkid
2007-05-19 22:20:17
A program that I made to test out arrays of forms, and having multiple forms showing at once.
Errors are common. I've come to the conclusion that it's SCAR, not the script.
Errors are common. I've come to the conclusion that it's SCAR, not the script.
program Spawner;
var
Form : Array [0..25] of TForm;
Button1 : Array [0..25] of TButton;
i, x, y : Integer;
procedure InitForm; forward;
procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;
procedure ShowFormModal;
begin
Form[i].SHOW;
end;
procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;
procedure Make;
begin
SafeInitForm;
SafeShowFormModal;
end;
procedure Spawn(Sender : TObject);
var
x : integer;
begin
if(i >= 25)then
begin
for x := 0 to 25 do
begin
FreeForm(Form[x]);
writeln('Form ' + inttostr(x) + ' freed');
end;
TerminateScript;
end;
i := i + 1;
//Form[i-1].HIDE;
//FreeForm(Form[i-1]);
Make;
Form[i].Caption := 'Form ' + inttostr(i) + '/25';
if(i = 25)then
for x := 0 to 25 do
Button1[x].Caption := 'Close all forms';
end;
Procedure InitForm;
begin
Form[i] := CreateForm;
GetClientDimensions(x, y);
Form[i].Left := random(x - 125);
Form[i].Top := RandomRange(25, y);
Form[i].BorderIcons := [biMinimize, biMaximize];
Form[i].BorderStyle := bsToolWindow;
Form[i].Caption := 'Form';
Form[i].ClientHeight := 25;
Form[i].ClientWidth := 125;
Form[i].Color := clBtnFace;
Form[i].Font.Color := clWindowText;
Form[i].Font.Height := -11;
Form[i].Font.Name := 'MS Sans Serif';
Form[i].Font.Style := [];
Form[i].Visible := True;
Form[i].PixelsPerInch := 96;
Button1[i] := TButton.Create(Form[i]);
Button1[i].Parent := Form[i];
Button1[i].Left := 0;
Button1[i].Top := 0;
Button1[i].Width := 125;
Button1[i].Height := 25;
Button1[i].Caption := 'Spawn new form';
Button1[i].TabOrder := 8;
Button1[i].Onclick := @Spawn
end;
begin
Make;
repeat
wait(10000);
until(isfkeydown(12))
end.