Solved

Message On Exit Application Problem

Posted on 2003-11-11
2
301 Views
Last Modified: 2010-04-05
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
Comment
Question by:tdk_man
2 Comments
 
LVL 2

Accepted Solution

by:
Trekker72 earned 50 total points
ID: 9727909
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
 
LVL 1

Author Comment

by:tdk_man
ID: 9727984
Yes, that's what I was after, thank you.

TDK_Man
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now