如何停止循环?(50分)

  • 主题发起人 主题发起人 城里的月饼
  • 开始时间 开始时间

城里的月饼

Unregistered / Unconfirmed
GUEST, unregistred user!
在各位老大的帮助下,我实现了从1到10000的显示,可我想用一个
button终止显示过程,怎么办呢?
 
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
canceled:boolean;
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
canceled:=true;
end;

procedure TForm1.Button2Click(Sender: TObject);
var i:integer;
begin
canceled:=false;
for i:=1 to 10000do
begin
application.ProcessMessages;
if canceled=true then
break;
label1.Caption:=inttostr(i);
label1.Refresh;
end;
end;

end.
 
可以用线程
 
同意leasun
 
接受答案了.
 
后退
顶部