In Lazarus I'm trying this:
TabSaveButton := TButton.Create(nil);
with TabSaveButton do
begin
Parent:=NewTab;
Width:=75;
Height:= 25;
Top:=530;
Left:=715;
Caption:='Save';
end;
And it works. I.e., I get the button and it's clickable, and it is the child of a dynamically created tab sheet.
But the following does not show the button, nor errors:
TabSaveButton := TButton.Create(NewTab);
with TabSaveButton do
begin
Width:=75;
Height:= 25;
Top:=530;
Left:=715;
Caption:='Save';
end;
Why does the second method not work?
Is this the same effect on both Lazarus and Delphi?
The argument of Create
sets the owner of the control. The owner is the component responsible for freeing the component in question. For instance, if you free a component, then all components owned by it are also freed. The parent is a completely different thing. It is the window (control) hosting the control in question.
There is no difference between Delphi and Lazarus here.