Cita:
Empezado por PaulaGV
probé el código, y esta muy bueno, pero no es exactamente lo que yo quiero hacer...
|
Hola Paula.
A ver si con este código nos aproximamos un poco a lo que buscas:
Código Delphi
[-]
implementation
uses Contnrs;
var
Pila: TStack;
Shape: TShape;
procedure TForm1.FormCreate(Sender: TObject);
begin
WindowState:= wsMaximized;
Pila:= Tstack.Create;
ListBox1.Align:= alLeft;
Randomize;
end;
procedure TForm1.btnAgregarClick(Sender: TObject);
begin
Shape:= TShape.Create(Self);
with Shape do
begin
Height:= 150;
Width := 250;
Left:= Random(Self.ClientWidth-500)+250;
Top := Random(Self.ClientHeight-320)+150;
Brush.Color:=RGB(Random(255),Random(255),Random(255));
case Random(6) of
0:begin
Shape:= stCircle;
ListBox1.Items.Add('Circulo');
end;
1:begin
Shape:=stRectangle;
ListBox1.Items.Add('Rectangulo');
end;
2:begin
Shape:=stSquare;
ListBox1.Items.Add('cuadrado');
end;
3:begin
Shape:=stRoundRect;
ListBox1.Items.Add('Rectangulo bordes redondeado');
end;
4:begin
Shape:=stEllipse;
ListBox1.Items.Add('elipse');
end;
5:begin
Shape:=stRoundSquare;
ListBox1.Items.Add('cuadrado bordes redondeado');
end;
end;
case Random(6) of
0:Pen.Style:=psSolid;
1:Pen.Style:=psDash;
2:Pen.Style:=psDot;
3:Pen.Style:=psDashDot;
4:Pen.Style:=psDashDotDot;
5:Pen.Style:=psClear;
end;
Parent:= Self;
end;
pila.Push(Shape);
end;
procedure TForm1.btnBorrarClick(Sender: TObject);
var
i: Integer;
begin
if Pila.Count > 0 then
begin
TShape(Pila.Pop).Free;
ListBox1.Items.Delete(ListBox1.Count-1);
end;
end;
procedure TForm1.btnBorraTodoClick(Sender: TObject);
var
i: Integer;
begin
for i:= Pila.Count-1 downto 0 do
TShape(Pila.Pop).Free;
end;
procedure TForm1.FormDestroy(Sender: TObject);
var
i: Integer;
begin
for i:= Pila.Count-1 downto 0 do
TShape(Pila.Pop).Free;
Pila.Free;
end;
Saludos.