Solved

Message On Exit Application Problem

Posted on 2003-11-11
2
308 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

691 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