你试试这样看看,你改一下用键盘的健就可以了 public re:integer;procedure TForm1.Button1Click(Sender: TObject); var count:integer; i:integer; begin re:=0; count:=11; while count<900 do begin for i:=1 to 888 do begin label1.caption:=inttostr(count+i); if re=1 then break; application.ProcessMessages; end; if count=899 then count:=11; end; end;procedure TForm1.Button2Click(Sender: TObject); begin re:=1; end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
var
Add:boolean=false;
procedure TForm1.Button1Click(Sender: TObject);
begin
Add:=not Add;
while add do
begin
application.ProcessMessages;
sleep(50);
edit1.Text:=inttostr(strtoint(edit1.Text)+1);
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
edit1.Text:='0';
end;end.
Label1: TLabel;
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
Add:boolean;
implementation{$R *.dfm}procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
Add:=not Add;
while add do
begin
application.ProcessMessages;
sleep(100);
Label1.Caption:=inttostr(strtoint(Label1.Caption)+1);
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
Label1.Caption:='0';
end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Label1: TLabel;
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
Add:boolean;
implementation{$R *.dfm}procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
Add:=not Add;
while add do
begin
application.ProcessMessages;
sleep(100);
Label1.Caption:=inttostr(strtoint(Label1.Caption)+1);
Label1.Left:=Label1.Left+1; //实现滚动,需要加以控制,否则可能会移出窗体
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
Label1.Caption:='0';
end;end.
public
re:integer;procedure TForm1.Button1Click(Sender: TObject);
var count:integer;
i:integer;
begin
re:=0;
count:=11;
while count<900 do
begin
for i:=1 to 888 do
begin label1.caption:=inttostr(count+i);
if re=1 then break;
application.ProcessMessages; end;
if count=899 then
count:=11;
end;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
re:=1;
end;end.
zzllabc(抱朴子--清心释累,绝率忘情) 你也要看清楚其中的不同之处,
jinjazz(人雅的标记--落寞刺客)用的是
procedure TForm1.Button1Click(Sender: TObject);
而我用的是
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
你看清楚了没有,并且我的代码是经过测试的,可能更加符合楼主说的要求。
对我是不会这么做的,我是看到jinjazz用的Button1Click事件,可能他误会楼主的意思了
所以我想改正过来,而且我的代码是运行过的,绝对不是敷衍了事,
请zzllabc(抱朴子--清心释累,绝率忘情)之流的人看清楚以后再说好吗,不要乱下定论。
他的才是正确的
var
Form1: TForm1;
stop : boolean ;
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
stop := false ;
self.KeyPreview := true ;
timer1.Enabled := stop ;
end;procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if stop then
timer1.Enabled := false else timer1.Enabled := true ;
stop := not stop ;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
Label1.Caption := inttostr(strtointdef(label1.Caption,0)+1);
end;
-> Sleep(0);