[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

Message On Exit Application Problem

Another one of those things I've forgotten, so easy points! :)

I have an exit button on my form. Click it and the following code is executed.

  If MessageDlg('Do You Really Want To Exit?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
    Close;

However, I want it to work on the window close 'X' gadget too, but when I put the code in OnClose or OnCloseQuery when I say yes to exit it doesn't until I've clicked three times and if I say No, it exits straight away.

Any ideas?
0
tdk_man
Asked:
tdk_man
1 Solution
 
Trekker72Commented:
try this

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  CanClose := MessageDlg('Do You Really Want To Exit?', mtConfirmation, [mbYes, mbNo], 0) = mrYes;
end;

cheers, terry
0
 
tdk_manAuthor Commented:
Yes, that's what I was after, thank you.

TDK_Man
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now