Author: Tomas Rutkauskas
How to prompt the user before closing the program
Answer:
Here's how to prompt users whether they really want to exit a program or not
(regardless of how they choose to close it). Place the following code in the
OnCloseQuery event of the form:
1 2 procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
3 begin4 if (mrNo = MessageDlg('You really want to exit?', mtInformation, [mbYes, mbNo],
5 0)) then6 begin7 CanClose := False;
8 end;
9 end;