unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls;
type
TForm1 = class(TForm)
btnOK: TButton;
btnAbbrechen: TButton;
procedure btnOKClick(Sender: TObject);
procedure btnAbbrechenClick(Sender: TObject);
function modalErgebnis(): String;
procedure FormActivate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btnOKClick(Sender: TObject);
begin
Form1.ModalResult:=mrOk;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
ShowMessage( modalErgebnis() );
end;
procedure TForm1.btnAbbrechenClick(Sender: TObject);
begin
Form1.ModalResult:=mrCancel;
end;
function TForm1.modalErgebnis(): String;
begin
if Form1.ModalResult=mrOk then
begin
result:='OK';
end
else if Form1.ModalResult=mrCancel then
begin
result:='Abbrechen';
end
else
begin
result:='False';
end;
end;
end.