unloadForm

unloadForm(): Boolean;

The unloadForm method of the Form class attempts to unload the form and returns whether the unload operation was successful, as listed in the following table.

Return Value Description
true The form was unloaded
false The request is denied by the queryUnload event generated by this method call

The form must have been created before it can be unloaded.

Use this method to cause the queryUnload and unload events of the form to be executed, even if the unload is performed in the load event of the form. The queryUnload method may reject the unload operation. If a form is unloaded before it is displayed and the load event has not been executed, the queryUnload and unload events are not executed.

If a queryUnload method is aborted, queryUnload is not called for any other forms affected by the unload and all affected forms are unloaded without calling the unload method. If an unload method is aborted, all other affected forms are unloaded without calling the unload method.

Unloading a form queues the window for deletion, but if another window is deleted before the next idle point, previously queued deleted windows are re-evaluated for deletion. If the queued window or its children have no outstanding Windows message, there are no incomplete event methods for that window or its children, and the method that created the window has exited or the window was deleted, the physical window is deleted.

If the form is defined as a Web page, the form is removed from the list of open forms maintained by the WebSession class. If the form is an MDI child and it is the last child of the default MDI frame form (supplied by JADE in jade.exe), the frame is also unloaded. If the form is the last running form, the application is also terminated.

The methods in the following examples show the use of the unloadForm method.

buttonUnload_click(btn: Button input) updating;
begin
    // Deletes the data and unloads the form.
    statusLine1.caption := "Deleting data...";
    statusLine1.refreshNow;
    beginTransaction;
        if numbers <> null then
            NumberDict.instances.purge;
            Number.instances.purge;
        endif;
    commitTransaction;
    unloadForm;
end;

cancelButton_click(btn: Button input) updating;
begin
    if app.checkForTransients(self) then
        app.msgBox("Transients remain", 'Warning', MsgBox_Information_Icon);
    endif;
    unloadForm;
end;