안녕하세요. 짱굽니다.
>subj 동적
악絿첩?동적 배열 생성에 대한 내용을 여러 가지 찾을 수 있을 겁니다.
다음 소스는 참고 하세요. 버튼을 동적으로 생성하는 것이죠...
[dbtn.pas]
unit Unit1;
interface
uses
Windows,
Messages,
SysUtils,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
ButtonArray: Array[0..9] of TButton;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
var
I : Integer;
begin
for I := 0 to 9 do
begin
ButtonArray[I]:= TButton.Create(Self);
with ButtonArray[I] do
begin
Parent:= Self;
Left:= 100;
Top:= I * 30;
Caption := format('Button%d',[I])
end;
end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
I : Integer;
begin
for I := 0 to 9 do ButtonArray[I].Free;
end;
end.
그럼 좋은 코딩 하세요.
|