Sometime we
need to add dialogbox for comfirmation in code to perform any action from user
to perform the operation. In these cases we can use “DialogButton” for the user
interaction no say “Yes/No” to execute the operation.
You can display a message in a modal dialog
box by using the Box class. Some methods in the Box class display a dialog box that contains multiple
buttons. These methods have a parameter for choosing which button has focus
when the dialog box is first displayed. This parameter is of type DialogButton enum. Most of these multiple-button methods return
a value of type DialogButton enum. This returned value enables your
program to branch based on which button the user clicked.
The following example displays a message box
that contains buttons labeled Yes, No, and Cancel. The No button
has initial focus. When a button is clicked, a message is displayed in
the Print Window to indicate which button was clicked.
Run this example as a job in the Application Object Tree (AOT).
Code:-
static void YesNoDialogBox() { DialogButton diagBut; str strMessage = "Are you sure want to update/Delete ?"; str strTitle = "Confirmation Message"; diagBut = Box::yesNo(strMessage,DialogButton::No, // Initial focus is on the No button. strTitle); if(diagBut == DialogButton::Yes) { startLengthyOperation(); Box::info("Click Yes","Message"); endLengthyOperation(); } else if(diagBut == DialogButton::No) { Box::info("Click No","Message"); } }
Thanks for comments.....