Closing a Dialog Box

Description

When a dialog box is displayed using the FORM.DIALOG() method, the user action of closing the dialog window actually closes the window.

Contrast this behavior with the FORM.VIEW() and FORM.LOAD() methods when the "Dialog" parameter is specified. In this case the user action of closing the dialog actually only hides the window so that the Xbasic program can read any of the variables that the user filled in on the dialog box. It is the responsibility of the Xbasic programmer to use the FORM.CLOSE() method to actually close the window. See the example below for details.

Examples 

Using the FORM.DIALOG() method. Assume that you have a form called "Print Report". The form has buttons called "Invoice Report", "Sales Report", "Customer Report" and "Cancel". ( Note : These names refer to the object names, not the text on the button face. Also note, that there are no Xbasic actions associated with each of these buttons other than " topparent.close()", which close the dialog box ). Depending on which button was pressed, you want to print the appropriate report. Here is how you could do it: This script could be a Global Script, or could be attached to a button on a form.

last_button = :Form.dialog("Print_Report")
select
    case last_button = "Invoice Report"
        :report.print("Invoice Report")
    case last_button = "Sales Report"
        :report.print("Sales Report")
    case last_button = "Customer Report"
        :report.print("Customer Report")
    case last_button = "Cancel"
end select

See Also