Is it possible to clone an object with another reference?
Here is an example what i'm trying to do: I have a TLabel
named Label1
. Now I want to create a Label2
, equals Label1
, able to be changed without reflect each other.
Ps: I'm using TLabel
as an example, I want to copy any object in another instance.
In the code below, I've tried changing the name, but the reference still the same, when a change one of them the other changes too.
var
cloneOfLabel1: TLabel;
begin
Label1.Caption := 'label 1';
cloneOfLabel1 := Label1;
cloneOfLabel1.Name := 'label2';
cloneOfLabel1.Caption := 'label 2';
cloneOfLabel1.Left := 0;
cloneOfLabel1.Top := Label1.Top+100;