A SERVICE OF

logo

Use TDialog::Execute to execute a dialog box modally When the user closes.
the dialog box, Execute returns an integer value indicating how the user
closed the dialog box. The return value is the identifier of the control the
user pressed, such as IDOK for the OK button or IDCANCEL for a Cancel
button. If the dialog box object was dynamically allocated, be sure to delete
the object.
The following example assumes you have a dialog resource
IDD_MY_DIALOG, and that the dialog box has two buttons, an OK button
that sends the identifier value IDOK and a Cancel button that sends some
other value:
if (TMyDialog(this, IDD_MY_DIALOG).Execute() == IDOK)
// User pressed OK
else
// User pressed Cancel
Only the object is deleted when it goes out of scope, not the dialog box
resource. Y u can create and delete any number of dialog boxes using onlyo
a single dialog-box resource.
Unlike a modal dialog box, you can continue to use other windows in your
Modeless dialog
application while a modeless dialog box is open. Y u can use a modelesso
boxes
dialog box to let the user continue to perform actions, find information, and
so on, while still using the dialog box.
Use TDialog::Create to execute a dialog box modelessly When using Create.
to execute a dialog box, you must explicitly make the dialog box visible by
either specifying the WS_VISIBLE flag for the resource style or using the
ShowWindow function to force the dialog box to display itself.
For example, suppose your resource script file looks something like this:
DIALOG_1 DIALOG 18, 18, 142, 44
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog 1"
{
PUSHBUTTON "Button", IDOK, 58, 23, 25, 16
}
Now suppose that you try to create this dialog box modelessly using the
following code:
.
.
.
TDialog dialog1(this, "DIALOG_1");
dialog1.Create();
.
.
.
Chapter 8, Dialog box objects
177