程序在事件的循环中,未何无法结束程序

dreamnyj 2007-03-01 12:33:59
procedure TForm1.Button1Click(Sender: TObject);
var Inti :integer;
begin
Inti := 1;

repeat

if InternetCheckConnection('http://zicheng.oicp.net/bbsxp', 1, 0) then
begin
edit1.text:= 'Connected';
Inti:=Inti+1;
Label1.Caption:=IntToStr(Inti);
ProgressBar1.Position:=Inti;
Application.ProcessMessages( ); {这里定义了处理消息,但就是点叉,不让关闭窗口
end
else
begin
edit1.text:= 'Disconnected';
Inti:=0;
end;


until Inti<=0;

end;
...全文
115 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
jadeluo 2007-03-01
  • 打赏
  • 举报
回复
在窗体类中增加一个Boolean类型变量来标记窗体被关闭

type
TForm1 = class(TForm)
......
private
bFormClosed : Boolean;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
bFormClosed := False;
end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
bFormClosed := True;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
Inti :integer;
begin
Inti := 1;
repeat
if InternetCheckConnection('http://zicheng.oicp.net/bbsxp', 1, 0) then
begin
edit1.text := 'Connected';
Inti := Inti+1;
Label1.Caption := IntToStr(Inti);
ProgressBar1.Position := Inti;
Application.ProcessMessages( ); {这里定义了处理消息,但就是点叉,不让关闭窗口
end
else begin
edit1.text := 'Disconnected';
Inti := 0;
end;
until bFormClosed or (Inti <= 0);
end;
dreamnyj 2007-03-01
  • 打赏
  • 举报
回复
受教了。。。非常感谢

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧