把主执行代码放在线程或定时器当中,就不会因为弹出对话框而停止。<br>比如一个简单的例子:<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, ExtCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Timer1: TTimer;<br> procedure FormActivate(Sender: TObject);<br> procedure Timer1Timer(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br> i:integer;<br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.FormActivate(Sender: TObject);<br>begin<br> application.ProcessMessages;<br> i:=0;<br> showmessage('aaa');<br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>begin<br> i:=i+1;<br> application.ProcessMessages;<br> caption:=inttostr(i);<br><br>end;<br><br>end.