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;