2005. december 9., péntek

Prompt the user before closing the program


Problem/Question/Abstract:

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:

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;

Nincsenek megjegyzések:

Megjegyzés küldése