unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if MessageDlg('
Wollen sie wirklich beenden ? (1)',
mtConfirmation, [mbYes, mbNo], 0) = mrYes
then
begin
close;
end else
begin
Windows.Beep(880,25);
MessageDlg('
Abgrbrochen durch Anwender',
mtConfirmation, [mbOK], 0);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if MessageBox(
Handle, '
Wollen sie wirklich beenden ? (2)',
'
Information', MB_ICONQUESTION
or MB_YESNO) = IDYES
then
begin
close;
end else
begin
MessageBox(
Handle, '
Abgrbrochen durch Anwender',
'
Information', MB_ICONINFORMATION
or MB_OK);
end;
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if MessageBox(
Handle, '
Wollen sie wirklich beenden ? (3)',
'
Form Close', MB_ICONWARNING
or MB_YESNO) = IDYES
then Action := caFree
else Action := caNone;
end;
procedure TForm1.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
if MessageBox(
Handle, '
Wollen sie wirklich beenden ? (4)',
'
Form Close Query', MB_ICONWARNING
or MB_YESNO) = IDYES
then CanClose := TRUE
else CanClose := FALSE;
end;
end.