Keeping a Dialog Open after Processing Events
IN THIS PAGE
Description
If, after the event_handling_code has processed an event generated by the dialog box, the a_dlg_button variable is set to a NULL value, the dialog is kept open. If a_dlg_button is set to any non-null value, the dialog is closed and the value in a_dlg_button is returned by the UI_DLG_BOX()function.
Trapping the OK Button
Therefore, in order to have the dialog remain open after the user dismisses the message box, all that we have to do is set a_dlg_button to a NULL value, as shown below:
Result = Ui_dlg_box("Title",<<%dlg%
Hello World;
<*15&OK> <&Cancel>
%dlg%,<<%code%
if a_dlg_button = "&OK" then
ui_msg_box("Notice","User clicked the OK button.")
a_dlg_button = ""
end if
%code%)Trapping the Cancel Button
To display a message box when the user presses the Cancel button, we have to include an event handler for the &Cancel event (which is generated when the Cancel button is pressed). Here is how this is done:
Result = Ui_dlg_box("Title",<<%dlg%
Hello World;
<*15&OK> <&Cancel>
%dlg%,<<%code%
if a_dlg_button = "&OK" then
a_dlg_button = ""
ui_msg_box("Notice","User clicked the OK button.")
end if
if a_dlg_button = "&Cancel" then
msg = "Are you sure you want to close the dialog?"
answer = ui_msg_box("Notice",msg,ui_yes_no)
if answer = ui_yes_selected then
a_dlg_button = "&Cancel"
else
a_dlg_button = ""
end if
end if
%code%)Limitations
Desktop applications only.
See Also