Mega Code Archive

 
Categories / Delphi / VCL
 

Componentleri dizi olarak kullanmak!

//Ersin Kecis. 23/04/2002. ersin@kecis.4t.com //asagida ornek olarak TButton componenti icin bir dizi var! unit Unit1; interface uses SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure ButtonClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} const b=4; var ButtonArray : Array[0..b-1] of TButton; MessageBox: TLabel; procedure TForm1.FormCreate(Sender: TObject); var loop : integer; begin ClientWidth:=(b*60)+10; ClientHeight:=65; MessageBox:=TLabel.Create(Self); MessageBox.Parent:=Self; MessageBox.Align:=alTop; MessageBox.Alignment:=taCenter; MessageBox.Caption:='Ersin Kecis. 24/04/2002. ersin@kecis.4t.com'; for loop:= 0 to b-1 do begin ButtonArray[loop]:=TButton.Create(Self); with ButtonArray[loop] do begin Parent :=self; Caption :=IntToStr(loop); Width :=50; Height :=25; Top :=30; Left :=(loop*60)+10; Tag :=loop; OnClick :=ButtonClick; end; end; end; procedure TForm1.ButtonClick(Sender: TObject); var t : Integer; begin t:=(Sender as TButton).Tag; MessageBox.Caption:=IntToStr(t)+'. butona bastınız.'; end; end.