ShowModal2 (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

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.

Code

procedure TMyDialogBox1.CancelButtonClick(Sender: TObject);
begin
  ModalResult := mrCancel;
end;

procedure TMyDialogBox1.OKButtonClick(Sender: TObject);
begin
  ModalResult := mrOK;
end;

Uses