private CanContinue: Boolean;procedure TForm1.Button1Click(Sender: TObject); var I: Integer; begin for I := 0 to 640000 do begin if not CanContinue then Exit; Application.ProcessMessages;//在合适的地方加上这句,也可以放在一个TTimer的事件中 Edit1.Text := IntToStr(I); Edit1.Update; end; end;procedure TForm1.Button2Click(Sender: TObject); begin CanContinue := False; end;procedure TForm1.FormCreate(Sender: TObject); begin CanContinue := True; end;————————————————————————————————— 宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。 —————————————————————————————————
设置全局变量FuncGoOn:Bool;在你的函数代码中,最外层套一个while While Not FuncGoOn Do //你原来的程序 End按'退出',FuncGoOn:=False;
上面修改,修改,设置全局变量FuncGoOn:Bool;在你的函数代码中,最外层套一个while While FuncGoOn Do //你原来的程序 End按'退出',FuncGoOn:=False;
谢谢,等待中... ^_^
CanContinue: Boolean;procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
for I := 0 to 640000 do
begin
if not CanContinue then Exit;
Application.ProcessMessages;//在合适的地方加上这句,也可以放在一个TTimer的事件中
Edit1.Text := IntToStr(I);
Edit1.Update;
end;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
CanContinue := False;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
CanContinue := True;
end;—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————
//你原来的程序
End按'退出',FuncGoOn:=False;
//你原来的程序
End按'退出',FuncGoOn:=False;