acaba Shape, Button gibi componentleri bir dizi şeklinde create edip Findcomponent kullanmadan çağırsam çok daha hızlı olur mu?. Bu şekilde Shape[1], Button[1] gibi oluşması için nasıl bir kod kullanmalıyım. Sanıtım IDE den değilde runtime sırasında oluşturmalıyım. Örnek kod olan arkadaş var mı?
İyi çalışmalar
incal99
Kod: Tümünü seç
For tamburno:=1 to 26 do begin
If TamburPosition[tamburno,1]<33 Then
begin
grid1:=36+(TamburPosition[tamburno,1]-1)*24;
with TBitBtn(Form2.FindComponent('BitBtn' + IntToStr(tamburno))) do Left := grid1;
with TShape(Form2.FindComponent('Shape' + IntToStr(tamburno+131))) do Left := grid1+4;
with TBitBtn(Form2.FindComponent('BitBtn' + IntToStr(tamburno))) do Top := 142-(TamburPosition[tamburno,2]-1)*50;
with TShape(Form2.FindComponent('Shape' + IntToStr(tamburno+131))) do Top := 157-(TamburPosition[tamburno,2]-1)*50;
end;
If TamburPosition[tamburno,1]>=33 Then
begin
grid1:=756-((TamburPosition[tamburno,1]-33)-1)*24;
with TBitBtn(Form2.FindComponent('BitBtn' + IntToStr(tamburno))) do Left := grid1;
with TShape(Form2.FindComponent('Shape' + IntToStr(tamburno+131))) do Left := grid1+4;
with TBitBtn(Form2.FindComponent('BitBtn' + IntToStr(tamburno))) do Top := 370-(TamburPosition[tamburno,2]-1)*50;
with TShape(Form2.FindComponent('Shape' + IntToStr(tamburno+131))) do Top := 388-(TamburPosition[tamburno,2]-1)*50;
end;
end;
For robotno:=1 to 4 do begin
If RobotPosition[robotno,1]<33 Then
begin
grid1:=32+(RobotPosition[robotno,1]-1)*24;
with TShape(Form2.FindComponent('Robot'+IntToStr(robotno)+'Shape1')) do Left := grid1;
with TShape(Form2.FindComponent('Robot' + IntToStr(robotno)+'Shape2')) do Left := grid1;
with TButton(Form2.FindComponent('Robot' + IntToStr(robotno)+'ButtonLeft')) do Left :=grid1-40+15;
with TButton(Form2.FindComponent('Robot' + IntToStr(robotno)+'ButtonRight')) do Left := grid1+15;
with TButton(Form2.FindComponent('Robot' + IntToStr(robotno)+'ButtonUpDown')) do Left := grid1-20+15;
with TShape(Form2.FindComponent('Robot' + IntToStr(robotno)+'Shape1')) do Top := 50;
with TShape(Form2.FindComponent('Robot' + IntToStr(robotno)+'Shape2')) do Top := 120;
with TButton(Form2.FindComponent('Robot' + IntToStr(robotno)+'ButtonLeft')) do Top := 40;
with TButton(Form2.FindComponent('Robot' + IntToStr(robotno)+'ButtonRight')) do Top := 40;
with TButton(Form2.FindComponent('Robot' + IntToStr(robotno)+'ButtonUpDown')) do Top := 40;
end;
If RobotPosition[robotno,1]>=33 Then
begin
grid1:=775-((RobotPosition[robotno,1]-32)-1)*24;
with TShape(Form2.FindComponent('Robot'+IntToStr(robotno)+'Shape1')) do Left := grid1;
with TShape(Form2.FindComponent('Robot' + IntToStr(robotno)+'Shape2')) do Left := grid1;
with TButton(Form2.FindComponent('Robot' + IntToStr(robotno)+'ButtonLeft')) do Left := grid1-40+15;
with TButton(Form2.FindComponent('Robot' + IntToStr(robotno)+'ButtonRight')) do Left := grid1+15;
with TButton(Form2.FindComponent('Robot' + IntToStr(robotno)+'ButtonUpDown')) do Left := grid1-20+15;
with TShape(Form2.FindComponent('Robot' + IntToStr(robotno)+'Shape1')) do Top := 280;
with TShape(Form2.FindComponent('Robot' + IntToStr(robotno)+'Shape2')) do Top := 350;
with TButton(Form2.FindComponent('Robot' + IntToStr(robotno)+'ButtonLeft')) do Top := 260;
with TButton(Form2.FindComponent('Robot' + IntToStr(robotno)+'ButtonRight')) do Top := 260;
with TButton(Form2.FindComponent('Robot' + IntToStr(robotno)+'ButtonUpDown')) do Top := 260;
end;
end;