
Kod: Tümünü seç
procedure TMasalar.FormCreate(Sender: TObject);
var
b:integer;
x1:array [1..100] of Tspeedbutton;
k,a,y,j,i:integer;
begin
a:=0;
b:=30; //cafedeki masa sayısı
for i:=1 to (floor(b/5)) do
for k:=1 to 5 do //bir satırda 6 tane buton olmasını istiyoruz.
begin //begin-end arasında buton oluşturuluyor.
a:=a+1;
x1[a]:=tspeedbutton.create(masalar);
x1[a].top:=(i-1)*90;
x1[a].left:=(k)*120;
x1[a].width:=100;
x1[a].height:=70;
x1[a].Caption:=inttostr(a);
x1[a].parent:=ScrollBox1;
x1[a].PopupMenu:=PopupMenu1;
x1[a].Font.Color:=clWhite;
x1[a].Font.Style:=[fsbold];
x1[a].Font.Size:=12;
x1[a].Flat:=true;
x1[a].Glyph.LoadFromFile('C:\Cafe otomasyonu\resimler\masa.bmp');
end;
y:=(b mod 5); //tam satırdan artan kaç masa olduğunu bulacağız ve onları ayrı
for j:=1 to y do //oluşruracağız.
begin
a:=a+1;
x1[a]:=TSpeedButton.create(masalar);
x1[a].top:=(floor(b/5))*90;
x1[a].left:=(j)*120;
x1[a].width:=100;
x1[a].height:=70; //butonun yüksekliği
x1[a].Caption:=inttostr(a);
x1[a].parent:=ScrollBox1; //scrollbox ın içinde oluşacak.
x1[a].PopupMenu:=PopupMenu1;
x1[a].Font.Color:=clWhite;
x1[a].Font.Style:=[fsbold];
x1[a].Font.Size:=12;
x1[a].Flat:=true;
x1[a].Glyph.LoadFromFile('C:\cafe otomasyonu\resimler\masa.bmp');
end;
end;