VovanZ
18-12-2009, 15:56
Этот код создаёт массив кнопок при нажатии на кнопку.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Buttons: array[1..10] of TButton;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i: Byte;
begin
for i := 1 to 10 do
begin
Buttons[i] := TButton.Create(Self);
with Buttons[i] do
begin
Parent := Form1;
Caption := 'Button ' + IntToStr(i);
Top := i * Height;
Tag := i;
Visible := True;
end;
end;
end;
end.
Как мне создавать массив кнопок при запуске программы?
P. S. Sorry за дурацкий вопрос, я не очень понимаю как в Делфи произходит созданиеобъектов и как работают ивенты...
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Buttons: array[1..10] of TButton;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i: Byte;
begin
for i := 1 to 10 do
begin
Buttons[i] := TButton.Create(Self);
with Buttons[i] do
begin
Parent := Form1;
Caption := 'Button ' + IntToStr(i);
Top := i * Height;
Tag := i;
Visible := True;
end;
end;
end;
end.
Как мне создавать массив кнопок при запуске программы?
P. S. Sorry за дурацкий вопрос, я не очень понимаю как в Делфи произходит созданиеобъектов и как работают ивенты...