MessageDlg (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example uses a button on a form. When you click the button, a message box asking if you want to exit the application appears. If you choose Yes, another dialog box appears, informing that the application is about to end. When you choose OK or close the dialog box, the application ends.

Code

procedure TForm1.Button1Click(Sender: TObject);
begin
  if Dialogs.MessageDlg('Welcome to my Delphi application.  Exit now?',
    mtConfirmation, [mbYes, mbNo], 0, mbYes) = mrYes then
  begin
    Dialogs.MessageDlg('Exiting the Delphi application.', mtInformation,
      [mbOk], 0, mbOk);
    Close;
  end;
end;

Uses

See Also