Главная страница | назад

Article #21592: A final prompt, asking user if they really want to exit.

How do I prompt a user, after they select a close method, for a response that they really want to close down the application?

Put this sample code into the OnCloseQuery event of your form. After a close method has been invoked on the form, a message will pop up asking the user if they really want to exit. If the user selects yes, the application will close normally, if they say no, the application will stay open.

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
 if (mrNo = MessageDlg('You really want to exit?', mtInformation, [mbYes, mbNo], 0)) then
    CanClose := False;

Last Modified: 05-APR-00