U don't want to free the local label because it is ponter to the one in the list.
See the attached project for an example
Of course it's possible.
See the example I gave, where every fpobjectlist entry is a reference to an actual label created in the normal way by dropping a component on the form.
Perhaps you need to post a (minimum) compilable project that fails to do what you are after.
As jamie pointed out you seem not to understand the difference between a label instance and a reference to that instance, and you "Free" references which should not ever be required.
Ensure the form (or some container) owns all your components, and let the automatic Freeing mechanism of ownership do the task for you. A reference can just be set to Nil when it is no longer useful or required.
Better to say that lbl is a reference held by (and retrieved from) the object list to the label on the form named 'Label4'.
procedure TForm1.GetNewLabelButtonClick(Sender: TObject); var lbl: TLabel; begin GetNewLabelButton.Enabled := False; lbl := GetLabel('label4', 9); with lbl do begin Font.Color := clYellow; AnchorSideLeft.Control := Label1; AnchorSideLeft.Side := asrRight; AnchorSideTop.Control := Label1; BorderSpacing.Left := 30; Parent := Self; end; end;
that lbl is just a reference to label4 in the object list? So if any properties change with lbl then the changes are kept with the control in the object list?
So I guess the difference here is lbl is assigned the return value of the GetLabel function and not a locally created object (label)?
Rich
So if I do:True.
lbl := Tlabel.create(false)
Then lbl is still a typed pointer variable but to a locally created object?