I am new to Delphi and my question may be very basic.
I created a Form in a Delphi procedure. Until now, I was using ShowModal() and then freeing all the objects that I want to avoid leaking after closing the Form.
Now, I would like to show the Form modeless, but I don't know how I can free the objects inside the OnClose event.
Does anybody know a solution for it?
Simply set the
Actionparameter tocaFree:Per the documentation:
Setting
ActiontocaFreewill cause the Form to callRelease()on itself after theOnClosehandler has exited:Release()posts a delayedCM_RELEASEmessage to the Form window. Once execution flow returns to the main message loop and the message is dispatched, the Form will free itself from memory.If your
TFormobject owns other objects, they will be freed automatically when theTFormis freed.