home *** CD-ROM | disk | FTP | other *** search
/ Delphi 4 Bible / Delphi_4_Bible_Tom_Swan_IDG_Books_1998.iso / source / MSGDLG / MAIN.PAS < prev    next >
Pascal/Delphi Source File  |  1998-04-10  |  2KB  |  94 lines

  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, Windows, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, ExtCtrls, Buttons;
  8.  
  9. type
  10.   TMainForm = class(TForm)
  11.     Button1: TButton;
  12.     Button2: TButton;
  13.     Button3: TButton;
  14.     Button4: TButton;
  15.     Button5: TButton;
  16.     BitBtn1: TBitBtn;
  17.     Label1: TLabel;
  18.     Panel1: TPanel;
  19.     Bevel1: TBevel;
  20.     Panel2: TPanel;
  21.     procedure Button1Click(Sender: TObject);
  22.     procedure Button2Click(Sender: TObject);
  23.     procedure Button3Click(Sender: TObject);
  24.     procedure Button4Click(Sender: TObject);
  25.     procedure Button5Click(Sender: TObject);
  26.   private
  27.     { Private declarations }
  28.   public
  29.     { Public declarations }
  30.   end;
  31.  
  32. var
  33.   MainForm: TMainForm;
  34.  
  35. implementation
  36.  
  37. {$R *.DFM}
  38.  
  39. procedure TMainForm.Button1Click(Sender: TObject);
  40. begin
  41.   ShowMessage('Procedure: ShowMessage');
  42. end;
  43.  
  44. procedure TMainForm.Button2Click(Sender: TObject);
  45. begin
  46.   ShowMessagePos('Procedure: ShowMessagePos', 10, 20);
  47. end;
  48.  
  49. procedure TMainForm.Button3Click(Sender: TObject);
  50. var
  51.   TheText, TheCaption: String;
  52. begin
  53.   TheText := 'Function: MessageBox';
  54.   TheCaption := 'MessageBox Demonstration';
  55.   if Application.MessageBox(PChar(TheText), PChar(TheCaption),
  56.     MB_DEFBUTTON1 + MB_ICONEXCLAMATION + MB_OKCANCEL) = IDOK
  57.     then ShowMessage('You selected OK')
  58.     else ShowMessage('You selected Cancel');
  59. end;
  60.  
  61. procedure TMainForm.Button4Click(Sender: TObject);
  62. var
  63.   W: Word;
  64.   S: String;
  65. begin
  66.   W := MessageDlg('Function: MessageDlg',
  67.     mtInformation, [mbYes, mbNo, mbIgnore], 0);
  68.   case W of
  69.     mrYes:    S := 'Yes';
  70.     mrNo:     S := 'No';
  71.     mrIgnore: S := 'Ignore';
  72.   end;
  73.   ShowMessage('You selected ' + S);
  74. end;
  75.  
  76. procedure TMainForm.Button5Click(Sender: TObject);
  77. var
  78.   W: Word;
  79.   S: String;
  80.   X, Y: Integer;
  81. begin
  82.   X := 50; Y := 75;
  83.   W := MessageDlgPos('Function: MessageDlgPos',
  84.     mtWarning, mbAbortRetryIgnore, 0, X, Y);
  85.   case W of
  86.     mrAbort:  S := 'Abort';
  87.     mrRetry:  S := 'Retry';
  88.     mrIgnore: S := 'Ignore';
  89.   end;
  90.   ShowMessage('You selected ' + S);
  91. end;
  92.  
  93. end.
  94.