?
Solved

Stop A Form from Closing

Posted on 1997-08-15
2
Medium Priority
?
178 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
[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 1

Accepted Solution

by:
peter_vc earned 80 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

649 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