(page requirements)
Downloads

Say no to program closings!

Here's how to prompt users whether they really want to exit your program or not (regardless of how they choose to close it):
 
  1. Select your form (named "Form1" for example) and double click on its "OnCloseQuery" event
     
  2. Define the "FormCloseQuery" procedure as follows:
 
procedure TForm1.FormCloseQuery(
  Sender: TObject;
  var CanClose: Boolean);
begin
  if(mrNo = MessageDlg(
       'Are you sure you want to exit?',
       mtInformation,
       [mbYes, mbNo],
       0)) then
  begin
    CanClose := False;
  end;
end;
Listing #1 : Delphi code. Download close (0.3 KB).
 
 
Applicable Keywords : Delphi, Delphi 1.x, Delphi 2.x, Delphi 3.x, Functions, Win32
 
 
 
Copyright © 2009 Chami.com. All Rights Reserved. | Advertise | Created in HTML Kit editor