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 FormKeyPress(Sender: TObject; var Key: Char);
procedure Button1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
InWorking: Boolean;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin
if InWorking then
begin
InWorking := False;
Exit;
end;
InWorking := True;
for i:=1 to 5 do
begin
showmessage(inttostr(i));
repeat
Application.ProcessMessages;
until not InWorking;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
InWorking:=False;
self.close;
end;
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
showmessage(key);
end;
procedure TForm1.Button1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=27 then
begin
InWorking:=False;
end;
end;
end.