Ver Mensaje Individual
  #7  
Antiguo 24-05-2012
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Cita:
Empezado por PaulaGV Ver Mensaje
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;

(* Crear Stack, valores iniciales *)
procedure TForm1.FormCreate(Sender: TObject);
begin
  WindowState:= wsMaximized;
  Pila:= Tstack.Create;
  ListBox1.Align:= alLeft;
  Randomize;
end;

(* Agregar un Shape *)
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;

(* Borrar un Shape *)
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;

(* Borrar todos los Shapes *)
procedure TForm1.btnBorraTodoClick(Sender: TObject);
var
  i: Integer;
begin
  for i:= Pila.Count-1 downto 0 do
    TShape(Pila.Pop).Free;
end;

(* Liberar *)
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.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita