简单的问题 我在用idlcmpclient1.ping循环ping几百个ip地址的时候,如何用一个按钮来终止这个事件??? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 循环过程中加入这句试试Application.ProcessMessages; unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; Button2: TButton; procedure Button2Click(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1; tt:Boolean;implementation{$R *.DFM}procedure TForm1.Button2Click(Sender: TObject);begin tt:=true;end;procedure TForm1.Button1Click(Sender: TObject);var i:integer;begin tt:=false; for i:= 0 to 100 do begin if tt then exit; edit1.Text:=inttostr(i); Application.ProcessMessages; sleep(100); end;end;end. unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; Button2: TButton; procedure Button2Click(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1; tt:Boolean;implementation{$R *.DFM}procedure TForm1.Button2Click(Sender: TObject);begin tt:=true;end;procedure TForm1.Button1Click(Sender: TObject);var i:integer;begin tt:=false; for i:= 0 to 100 do begin if tt then exit; edit1.Text:=inttostr(i); Application.ProcessMessages; sleep(100); end;end;end. 循环过程中或循环外(在当前按钮中)加入Application.ProcessMessages;用以响应其它消息Break命令终止for、while、repeat循环语句 我虽然不知道你的提问,但我觉得楼上两位的回答并不正确,Application.ProcessMessages;加上这句,能响应其他的事件,比如一个按钮的click事件,但如何在 click事件中如何终止这个循环,并没有给出解答。break只是退出本次循环,它在循环的内部,但却不能由其他的事件来触发。 定义全局变量tt再循环中判断ttApplication.ProcessMessages;for i:=1 to 10000 dobegin if tt=false then //执行代码 else break; end;在另外一个按钮click事件中加入tt:=true; 我怎么错了 花钱求人开发一个IE控件,能够安装在IE浏览器上的,就像google.com安装在IE地址栏下的工具条( 请问手机软件到底是如何开发的? 关于ADO更新数据问题? 奇怪的SQL错误? ComboBox框的AutoComplete问题 请问.bpl是什么文件,怎样看到源码。 希望能和这里的朋友认识一下! 这种变量怎么申请? delphi5是不是自己有个系统托盘图标组件?我怎么在控件板上找不到? 图片保存方法 动态生成变量的问题,望各位帮忙!
Application.ProcessMessages;
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
tt:Boolean;
implementation{$R *.DFM}procedure TForm1.Button2Click(Sender: TObject);
begin
tt:=true;
end;procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
tt:=false;
for i:= 0 to 100 do
begin
if tt then exit;
edit1.Text:=inttostr(i);
Application.ProcessMessages;
sleep(100);
end;
end;end.
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
tt:Boolean;
implementation{$R *.DFM}procedure TForm1.Button2Click(Sender: TObject);
begin
tt:=true;
end;procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
tt:=false;
for i:= 0 to 100 do
begin
if tt then exit;
edit1.Text:=inttostr(i);
Application.ProcessMessages;
sleep(100);
end;
end;end.
Application.ProcessMessages;
用以响应其它消息
Break命令终止for、while、repeat循环语句
加上这句,能响应其他的事件,比如一个按钮的click事件,但如何在 click事件中如何终止这个循环,并没有给出解答。break只是退出本次循环,它在循环的内部,但却不能由其他的事件来触发。
定义全局变量tt
再循环中判断tt
Application.ProcessMessages;
for i:=1 to 10000 do
begin
if tt=false then
//执行代码
else
break;
end;在另外一个按钮click事件中加入
tt:=true;