StevenV
2014-05-09 12:11:57
i'm trying to make an onclick event for a dynamical form. But it won't work, it alsways gives an error 'identifier not found'
i've searched around on different places and i used their help but nothing seemed to help me out
here is the script:
i've searched around on different places and i used their help but nothing seemed to help me out
here is the script:
unit unit22;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm2 }
TForm2 = class(TForm)
Procedure Nieuw(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form2: TForm2;
Label2: Tlabel;
Button2: Tbutton;
Labels: Array of TLabel;
Buttons: Array of Tbutton;
i: integer;
AantalStammen: integer;
Stammen: Array of String;
Procedure Test2;
implementation
Procedure TForm2.Nieuw(Sender: TObject);
begin
showmessage('nieuwe stam');
end;
Procedure Test2;
begin
SetLength(Labels, AantalStammen-1);
SetLength(Buttons, 3);
if AantalStammen>1 then
for i:= 0 to AantalStammen-1 do
begin
Labels[i]:=TLabel.Create(Label2);
try
with Labels[i] do
begin
Parent:=Form2;
Left:=50;
Top:=10+25*(i);
Labels[i].Caption:= Stammen[i] ;
end;
except
Labels[i].Free;
end;
end;
Form2.height:=AantalStammen*25+75;
for i:= 0 to 2 do
begin
Buttons[i]:=Tbutton.Create(Button2);
try
with Buttons[i] do
begin
Buttons[i].Parent:=Form2;
Buttons[i].width:=100;
Buttons[i].height:=25;
Buttons[i].Left:=25+(125*i);
Buttons[i].Top:=Form2.height-50;
end;
except
Buttons[i].Free;
end;
end;
Buttons[0].Caption:= 'Nieuw';
Buttons[1].Caption:= 'Wijzigen';
Buttons[2].Caption:= 'Sluiten';
Buttons[0].OnClick:= Nieuw;
Form2.width:=3*125+25;
Form2.show;
end;
{$R *.lfm}
end.