Jump to content

Question about freeing frame on tabsheet pagecontrol


d.bernaert

Recommended Posts

Hello,

I'm creating dynamically tabsheets on a unipagecontrol.

On these tabsheets I host Uniframes that are created together with the tabsheet.

The user can close tabsheets.

My question is the following, when the user closes a tabsheet, the tabsheet is freed. Will the uniframe hosted on the tabsheet also be automatically freed or does this need to be done manually?

Thx,

Dominique

Link to comment
Share on other sites

1. When create a frames, set owner tabsheet.

https://www.thoughtco.com/owner-vs-parent-in-delphi-applications-1058218

Quote

Every Delphi component has an Owner property. The Owner takes care of freeing the owned components when it is being freed.

 

Destroying ParentTab will also destroy the frame:

procedure TfmMain.CreateFrame(ParentTab: TUniTabSheet; UniFrameMyClass: TUniFrameMyClass);
begin
  UniFrame := UniFrameMyClass.Create(ParentTab);// ParentTab will be owner
  UniFrame.Parent := ParentTab;
  UniFrame.Show;
end;

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...