Solved

Stop A Form from Closing

Posted on 1997-08-15
2
164 Views
Last Modified: 2010-04-06
I want to stop a MDI form from closing unless certain criteria is set.  I also want to prevent a form from closing if Ctrl-F4 is pressed.  I know I can stop this two ways, either writing code on the onCloseQuery or setting the Crtl-F4 key press to zero.  My problem is, 1) after setting the criteria in the onCloseQuery - what is the code that actually STOPS the form from closing and 2) how do you set CTRL-F4 to zero?  I'm hoping writing code in the onCloseQuery stops a CTRL-F4 key press, but if it doesn't, I need answers to both questions.
0
Comment
Question by:d4jaj1
2 Comments
 
LVL 1

Accepted Solution

by:
peter_vc earned 20 total points
ID: 1341567
procedure TMDIChild.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  { if form not allowed to close then }

     Action := caNone;

  { else }

     Action := caFree;

end;

This should do the trick.

0
 
LVL 3

Author Comment

by:d4jaj1
ID: 1341568
Great Job.  I've asked this question, what seems to be a vey simple question four times, each receiving a wrong answer.  Thanks for finally giving me an answer that works!
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

770 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