用如此方法可以控制:
procedure Form1.FormClose(Sender: TObject;
var Action: TCloseAction);
var I:Integer;
begin
I:=Application.MessageBox
('MY_MESSAGE','Title',MB_YESNOCANCEL+MB_ICONSTOP);
Case I of
2: Application.Run;{返回应用程序}
6: ....;{YES to close}
7: ....;{NO to close}
end;
对不起,刚才写错了,应该是
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if Application.MessageBox('是否关闭窗口?','询问', Mb_OKCancel)=ID_Cancel then
Action:=False;
//则窗口就不关闭了
end;