procedure TForm1.Button1Click(Sender: TObject);begin while true do begin sleep(30)
application.ProcessMessages
if Application.Terminated then break
end;end;给分,呵呵
application.ProcessMessages;在循环过程中,它是屏蔽了 wm_close 消息的所以你不可能简单的在循环过程中关闭窗体,我的经常用的方法是一设置一全局变量var fclose:boolean:=false;在 formclose 或 wmdproc 截取 wm_close 里设置fclose:=true;在procedure TForm1.Button1Click(Sender: TObject);里修改如下:begin while not fclose do begin sleep(30)
application.ProcessMessages
end
if fclose then this.close;end;