home *** CD-ROM | disk | FTP | other *** search
/ Delphi 4 Bible / Delphi_4_Bible_Tom_Swan_IDG_Books_1998.iso / source / YESNO / MAIN.PAS < prev    next >
Pascal/Delphi Source File  |  1998-04-13  |  1KB  |  61 lines

  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, Windows, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, YesNo;
  8.  
  9. type
  10.   TMainForm = class(TForm)
  11.     TestButton: TButton;
  12.     ExitButton: TButton;
  13.     procedure TestButtonClick(Sender: TObject);
  14.     procedure ExitButtonClick(Sender: TObject);
  15.   private
  16.     { Private declarations }
  17.   public
  18.     { Public declarations }
  19.   end;
  20.  
  21. var
  22.   MainForm: TMainForm;
  23.  
  24. implementation
  25.  
  26. {$R *.DFM}
  27.  
  28. procedure TMainForm.TestButtonClick(Sender: TObject);
  29. { Add following two lines to create a variable for
  30.   storing the result of the YesNo dialog. }
  31. var
  32.   Result: Integer;
  33. begin
  34.   { Make the dialog caption match the application's for
  35.     easier switching away then back. }
  36.   YesNoDlg.Caption := MainForm.Caption;
  37.   { Use following statement to change prompt at runtime,
  38.     or you can set the dialog's Caption property. }
  39.   YesNoDlg.PromptLabel.Caption := 'Click any button. Okay?';
  40.   { Display the dialog and save its result, which equals
  41.     the ModalResult property of the button clicked to close
  42.     the YesNo dialog.}
  43.   Result := YesNoDlg.ShowModal;
  44.   if Result = mrYes
  45.   then
  46.     ShowMessage('You selected the Yes button!')
  47.   else if Result = mrNo
  48.   then
  49.     ShowMessage('You selected the No button!')
  50.   else
  51.     ShowMessage('Unknown button!');  { Never shown }
  52. end;
  53.  
  54. procedure TMainForm.ExitButtonClick(Sender: TObject);
  55. begin
  56.   Close;
  57. end;
  58.  
  59. end.
  60.  
  61.