Einzelnen Beitrag anzeigen

Benutzerbild von ATS3788
ATS3788

Registriert seit: 18. Mär 2004
Ort: Kriftel
646 Beiträge
 
Delphi XE Starter
 
#1

Schnelles erstellen von Objekten

  Alt 10. Jan 2016, 07:43
Hallo erst mal frohes neues Jahr

Ich habe da eine kleine "Procedure"
und erstelle TShape Objekte.
Das dauert doch recht lange.
Meine frage, wie macht man so etwas besser schneller ?


Delphi-Quellcode:

const
cX = 10;
cY = 10;

_X = 320;
_Y = 240;
var
x, y: Integer;
counter : Integer;
begin
 try
    ScBox.Visible := False;
counter := 1;

    for x := 1 to _X do
      for y := 1 to _Y do begin
     shape := TShape.Create(ScBox);
     shape.Name := 'shape' + IntToStr(counter);
     shape.Parent := ScBox;
     shape.Width := cX;
     shape.Height := cY;
     shape.Brush.Color := clPurple;
     shape.Shape := stRectangle;

     shape.Left := x * cX;
     shape.Top := y * cY;

     if counter mod 150 = 0 then begin
     Shape1.Brush.Color := Random($ffffff);
     StPan1.Caption := ' Pixel : ' + IntToStr(counter);
     Application.ProcessMessages;
     end;

     inc(counter);
      end;

finally
    ScBox.Visible := True;

 end;
end;
Martin MIchael
  Mit Zitat antworten Zitat