OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Modal dialog boxes

Most dialog boxes are modal.

While a modal dialog box is displayed, the user cannot select or use its parent window, but rather must close the dialog box before proceeding. In effect, a modal dialog box freezes the operation of the rest of the application.

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.

Example

The following example assumes you have a dialog resource IDD_MYDIALOG, 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(TDialog(this, IDD_MYDIALOG).Execute() == IDOK)
// User pressed the OK button.
else
// User pressed Cancel.

Only the object is deleted when it goes out of scope, not the dialog box resource. You can create and delete any number of dialog boxes with a single dialog box resource.

See Also