Putting a Button on the Dialog

Description

Let's now make the "Hello World" dialog a little more complex by adding a button to the dialog.

result=ui_dlg_box("Title",<<%dlg%
Hello World

%dlg% )

This command creates this dialog:

A button is placed on a dialog box using the '<' and '>' delimiters. In this simple case, the buttons do not do anything. When you press either of the buttons, the dialog box is closed, and "result" contains the text of the button that was pressed. If the user closes the dialog by clicking on the "X", or by pressing the Escape key, result will contain an empty string. For example, the following Xbasic script tests what button was pressed:

result = ui_dlg_box("Title",<<%dlg%
Hello World

%dlg% )
if result = "OK" then
    ui_msg_box("Note", "User pressed OK")
else if result = "Cancel" then
    ui_msg_box("Note", "User pressed Cancel")
else if result = "" then
    ui_msg_box("Note", "User pressed Esc, or clicked on the X")
end if

See Also