ShowModal2 (C++)

From RAD Studio Code Examples
Jump to: navigation, search


The following methods are used for buttons in a form that is used as a modal dialog box. The methods cause the dialog box to terminate when you click either the OK or Cancel button, returning mrOk or mrCancel from ShowModal, respectively. You could also set the ModalResult value to mrOk for the OK button and mrCancel for the Cancel button to accomplish the same thing. When you click either button, the dialog box closes.


void __fastcall TMyDialogBox1::OKButtonClick(TObject *Sender)
  ModalResult = mrOk;

void __fastcall TMyDialogBox1::CancelButtonClick(TObject *Sender)
  ModalResult = mrCancel;