Today, Delphi is one of the popular desktop programming tool. There are thousand even million programmer in this world using delphi as their favorit tool. This site try to collect the examples, tips and tricks of Delphi programming. We collect, test them and redistribute the collection of delphi programming for you.

YesNoCancel Message Box with Case of

Author: admin | Category: Tips and Tricks

//This is how we can make a message box with Yes No Cancel button and  use "Case of" to response
//using button1 tho show the message box
 
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
 
type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.Button1Click(Sender: TObject);
var
    userResponse:integer;
begin
    userResponse := MessageDlg('Choose Yes no or Cancel?', mtConfirmation, mbYesNoCancel, 0);
    case userResponse of
      idYes: ShowMessage('You choose Yes');
      idNo: ShowMessage('You choose no');
      {if the response is Cancel nothing will happen...}
      idCancel: ;
    end;
end;
 
end.

Tags: