Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Owner = nil or Owner = Self on dynamic form creation?
To conserve resources, I am setting up dynamic creation of forms that may not be used while my application runs. I am not sure what the best Owner is for a dynamically created form. With a nil Owner, there isn't the Notification method performance hit, but I think you have to use Free (or FreeAndNil) to get rid of it. I'd prefer to use the Release method to destroy the form object so that event handling on the dynamically created form is completed before the form is destroyed, but I understand that to use that I'd need to specify an Owner.
with TMyForm.Create(Self) do //Self = the calling form
with TMyForm.Create(nil) do
Free; //or FreeAndNil(MyFormVar)
Sorry for this elementary question; I'm relatively new to Delphi. Any opinions on this subject would be greatly appreciated. Thanks~
0 · ·