procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);begin if MessageDlg('Close the form?', mtConfirmation, [mbOk, mbCancel], 0) = mrCancel then CanClose := False; end;
有多种方法,建议在主窗体的OnCloseQuery事件中书写如下代码:procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin if Application.MessageBox('你真的想要退出程序吗?','退出确认',MB_YESNO)=IDNO then canclose:=false; end;
if MessageDlg('Close the form?', mtConfirmation,
[mbOk, mbCancel], 0) = mrCancel then
CanClose := False;
end;
begin
if Application.MessageBox('你真的想要退出程序吗?','退出确认',MB_YESNO)=IDNO then
canclose:=false;
end;