Ian Branch 127 Posted May 21, 2021 Hi Team, What are the Pros & Cons, and preference, of using Nil v Self in something like.. MyForm := TMyForm.Create(nil); // Nil or self. // try MyForm.ShowModal; finally FreeAndNil(MyForm); end; // Regards & TIA, Ian Share this post Link to post
David Heffernan 2345 Posted May 21, 2021 Doesn't matter. May as well use nil. Share this post Link to post
Fr0sT.Brutal 900 Posted May 21, 2021 Nil is when you destroy it explicitly Self is when you leave it until owner is destroyed Share this post Link to post
Anders Melander 1783 Posted May 21, 2021 Regardless of how it affects the instance ownership, if the Form has Position=poOwnerFormCenter then the Owner should be specified Otherwise it will fall back to poMainFormCenter. 2 Share this post Link to post
Guest Posted May 23, 2021 On 5/21/2021 at 9:29 AM, Fr0sT.Brutal said: Nil is when you destroy it explicitly Self is when you leave it until owner is destroyed That is like... 30% of the information needed to understand the concept. VCL object management do work. And is properly documented. Share this post Link to post
Fr0sT.Brutal 900 Posted May 24, 2021 17 hours ago, Dany Marmur said: That is like... 30% of the information needed to understand the concept. Well, I don't consider it effective talking about integrals in answer to question "2+2=?". Anyway these 30% is much greater than 0% in David's answer :D Share this post Link to post