unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, Buttons;

type
  TMainForm = class(TForm)
    btnOBLICZAJ: TBitBtn;
    eCyfra: TEdit;
    Label1: TLabel;
    Panel1: TPanel;
    btnCLOSE: TBitBtn;
    procedure FormCreate(Sender: TObject);
    procedure btnOBLICZAJClick(Sender: TObject);
    procedure btnCLOSEClick(Sender: TObject);
  private

  public
    procedure MyOnException(Sender : TObject; e : Exception);
	// void __fastcall TForm1::MyOnException(System::TObject* Sender, Sysutils::Exception* E)
  end;

var
  MainForm: TMainForm;

implementation
{$R *.dfm}
{------------------------------------------------------------------------------}

procedure TMainForm.btnCLOSEClick(Sender: TObject);
begin
	Close();
end;

procedure TMainForm.btnOBLICZAJClick(Sender: TObject);
var
   kom     : String;
   kwadrat : Integer;
   cyfra   : Integer;

begin
	kom     := '';
	kwadrat := 0;
	cyfra   := 0;


   cyfra   := StrToInt(eCyfra.Text);
   kwadrat := cyfra * cyfra;
   kom     := 'Cyfra: ' + eCyfra.Text + ' do kwadratu := ' + IntToStr(kwadrat);

   ShowMessage(kom);
end;

procedure TMainForm.FormCreate(Sender: TObject);
begin
   Application.OnException := MyOnException;
end;

procedure TMainForm. MyOnException(Sender : TObject; e : Exception);
begin
   // tutaj skieruj komunikaty do pliku-
   ShowMessage('Moja funkcja obsługi nieobsłużonych wyjątków');
   Application.ShowException(E);
   Application.Terminate();
end;

end.
