Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Message On Exit Application Problem

Posted on 2003-11-11
2
Medium Priority
?
314 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
Trekker72 earned 200 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

609 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