unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    Button1: TButton;
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure FormCreate(Sender: TObject);
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
    procedure Button1Click(Sender: TObject);
  private
   zamknij:boolean;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

uses Unit1;

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
begin
 if Edit1.text='Ala' then
  begin
   Form1.Show;
   zamknij:=true;
   Form2.Close;
  end
  else label1.caption:='bledne haslo';
end;

procedure TForm2.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
 if key=#13 then button1.click;
end;

procedure TForm2.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose:=zamknij;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
 zamknij:=false;
end;

end.
