我想在让程序在后台运行的时候,然后还可以响应其他事件
例如:
for i:=0 to 1000000000000 do
begin
label1.caption:=IntToStr(i);
label1.refresh;
end;那我想在这个程序运行过程中,可以让用户点Cancel按扭??????
例如:
for i:=0 to 1000000000000 do
begin
label1.caption:=IntToStr(i);
label1.refresh;
end;那我想在这个程序运行过程中,可以让用户点Cancel按扭??????
解决方案 »
- 主线程如果终止后 由它生成的线程会不会也终止
- 能在一个 DBGrid 中显示 两个不同 数据库中 的两个表中的 内容?
- 急急,,,在家幫我看看這些代碼是什么意思...
- 喷墨打印机支持逐行打印吗?
- 如何把double类型的小数点控制在两位,而不出现类似9.8999999999这样的数。
- 北京的朋友看过来!
- 2个adodataset之间的数据转换问题
- delphi +MO
- 为什么BUTTON得按两次才能显示文件搜索结果
- delphi5中可不可以定义二维变长数组,如何定义?
- String 与Array \word\int赋值问题
- 有多少人用过Delphi的web service?是不是delphi是比较差的开发工具?用jbuilde,如何
begin
label1.caption:=IntToStr(i);
label1.refresh;
Application.ProcessMessages;
end;
for i:=0 to 1000000000000 do
begin
if Terl then Break;
label1.caption:=IntToStr(i);
label1.refresh;
end;Btn_Cancel.clickTelr:=True;
在procedure tform1.cancelOnClick(...)
begin
b_cancel:= true;
end;
for i:=0 to 1000000000000 do
begin
label1.caption:=IntToStr(i);
label1.refresh;
if b_cancel then break;
end;
Var
I: Integer;
begin
For I := 0 To 10000000 Do
begin
Label1.caption:=IntToStr(i);
Label1.refresh;
Application.ProcessMessages;
If WantT then
Begin
Break;
WantT := False;
End;
end;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
WantT := True;
end;procedure TForm1.FormActivate(Sender: TObject);
begin
WantT := False;
end;
Var
I: Integer;
begin
For I := 0 To 10000000 Do
begin
Label1.caption:=IntToStr(i);
Label1.refresh;
Application.ProcessMessages;
If WantT then
Begin
WantT := False;
Break;
End;
end;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
WantT := True;
end;procedure TForm1.FormActivate(Sender: TObject);
begin
WantT := False;
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
IsBreak:boolean;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
IsBreak:=False;
for i:=0 to 1000000 do
begin
label1.caption:=IntToStr(i);
label1.refresh;
Application.ProcessMessages;
if IsBreak then break;
end;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
IsBreak:=True;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
IsBreak:=False;
end;end.上面程序在D6验证通过
在procedure tform1.cancelOnClick(...)
begin
b_cancel:= true;
end;
for i:=0 to 1000000000000 do
begin
label1.caption:=IntToStr(i);
label1.refresh;
Application.ProcessMessages;
if b_cancel then break;
end;
for i:=0 to 1000000000000 do
begin
Application.ProcessMessages;
label1.caption:=IntToStr(i);
label1.refresh;
end;
楼上说不行的是瞎说,不要相信他
我不想中断一个而去执行另外一个程序,我需要两者同时运行其实在VB 中就很容易实现这个问题:DoEvents就搞定,无奈我是delphi菜鸟,请大家多多帮忙