任选其一,不要两个都用呀[]
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if Application.MessageBox('确实要退出吗?', '询问', 32 + mb_YesNo) = mrNo then
Action := caNone;
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if Application.MessageBox('确实要退出吗?', '询问', 32 + mb_YesNo) = mrNo then
CanClose := False;
end;