[Lazarus] How to clone a component

patspiper patspiper at gmail.com
Wed Oct 3 23:33:07 CEST 2012


Hi,

What is the correct way to clone programmatically a component, ie assign 
all its properties to another component of the same class (like the IDE 
designer's copy/paste)?

The code below used to work in Delphi but does not with Lazarus (result 
is nil).
     RegisterClass(TMyComponent);
     Clipboard.SetComponent(MyComponent);
     Result:= TMyComponent(Clipboard.GetComponent(Self, Self));

Stephano




More information about the Lazarus mailing list