What are the ways to close a modal form? - Delphi

What are the ways to close a modal form?



- The modal form uses a close method and it executes using the OnClose event that checks whether the data is saved or not and then take some actions according to it.

- The Close method that is being used by the modal form doesn’t free the memory that is associated with the modal form.

- The form’s Release method is called if the modal form needs to be closed without checking any condition.

- There is a Free method that can also be used as it allows the control to be freed from the process but it includes event handlers that run with the memory.

- The Modal forms set the form’s ModalResult property greater than zero. It can be done by using the function as:

result := Form.ShowModal.
Post your comment

    Discussion

  • RE: What are the ways to close a modal form? - Delphi -Shadab Mozaffar (07/22/15)
  • I prefer using Application.CreateForm and then FreeAndNil to release all related memory to this form. It also discard all changes made to it on runtime, so that on every CreateForm call, you get what you had designed.