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





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

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

Answer:
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);
begin
if (mrNo = MessageDlg('You really want to exit?', mtInformation, [mbYes, mbNo], 0)) then
begin
CanClose := False;
end;
end;

Last Modified: 05-APR-00