unit Main;

interface

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

type
  TMainForm = class(TForm)
    Panel1: TPanel;
    btnCLOSE: TBitBtn;
    btnSTART: TBitBtn;
    procedure btnSTARTClick(Sender: TObject);
    procedure btnCLOSEClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  MainForm: TMainForm;

implementation
{$R *.dfm}

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

procedure TMainForm.btnSTARTClick(Sender: TObject);
var
	mr : TModalResult;

begin
	if not Assigned(Form2) then
   begin
		try
         // podaj
         // Form2 := TForm2.Create(Nil);
         // lub
         // Form2 := TForm2.Create(Application);
         // lub
         // Form2 := TForm2.Create(MainForm);
         // lub
			Form2 := TForm2.Create(Self);
         mr := Form2.ShowModal();

         if mr = mrOk then
         begin
         	ShowMessage('Okno zamkniête klawiszem OK');
         end
         else begin
         	ShowMessage('Operacje anulowane');
         end;
      finally
      	FreeAndNil(Form2);
      end;
   end;
end;

end.

