传出参数,如果用户终止程序,则在mainForm里面跳出create方法,这样就可以了 formcreate { ..... try frmChild.showmodal; finally bT:=frmChild.bTerminate; frmChild.free; end; if not bt then exit; ..... }
不好意思,刚才忘记加application.Terminate formcreate { ..... try frmChild.showmodal; finally bT:=frmChild.bTerminate; frmChild.free; end; if not bt then begin application.Terminate; exit; end; ..... }
formcreate
{
.....
try
frmChild.showmodal;
finally
bT:=frmChild.bTerminate;
frmChild.free;
end;
if not bt then
exit;
.....
}
formcreate
{
.....
try
frmChild.showmodal;
finally
bT:=frmChild.bTerminate;
frmChild.free;
end;
if not bt then
begin
application.Terminate;
exit;
end;
.....
}
但它络止程序必须有个条件,必须等Application.Terminate
之后的所有代码执行完毕,所以它不会“立即终止",
其实它只不过给了信号,仅仅使:
属性Appliaction.Terminted变为真而已,
执不执行“终止”,它是不管的,直到用户之后代码执行完了
系统才真的执行。
如果这样:
Application.Terminate;
死循环;
。
它永远都不能终止程序,但其后的代码可测试到
Application.Terminated变为真了,
你应做相应的终止处理了
begin
Appliaction.Terminted
Exit;//加上之后就可以完全退出应用程序。
end;