Tips (1541)
{ This code shows how to clone a TPanel (Panel1) You can do it with any other component Dieser Code zeigt, wie ein TPanel (Panel1) geklont werden kann. Das funktioniert natürlich auch mit anderen Komponenten } procedure TForm1.Button1Click(Sender: TObject); var ms: TMemoryStream; s: string; p, temp: TPanel; x,y: Integer; begin ms := TMemoryStream.Create; try temp := panel1; s := panel1.Name; panel1.Name := ''; try ms.WriteComponent(temp); ms.Position := 0; p := TPanel.Create(Self); ms.ReadComponent(p); with p do begin x := panel1.Left; y := panel1.Top; Inc(x, 5); Inc(y, 5); SetBounds(x, y, Width, Height); Parent := Self; Name := Format('Panel%d_%d', [x, y]); end; finally temp.Name := s; panel1 := temp; end finally ms.Free; end; { finally } end;
Rate this tip: