Solved

Terminating application - preventing

Posted on 2001-07-24
6
154 Views
Last Modified: 2010-04-06
I would like to control when user is allowed to close my application either trough Alt-F4 or normaly trough app.
I need to prevent closing of app while I initialise my program (conecting to TCP, loading data etc.).  
0
Comment
Question by:TomazB
6 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 6311809
just fill out the onclosequery-event

as long it is not allowed,
set there the canclose-var to false
0
 
LVL 2

Expert Comment

by:FrodoBeggins
ID: 6311879
Yes, you need to handle OnCloseQuery event on your main form and set the parameter CanClose to False. That ensures that your app will not die by ExitProcess(...) function (e.g. by pressing Alt+F4).
But your process still can be terminated by TerminateProcess(...) function (by any other process, e.g. Task Manager). There is no way to be 100% sure your app will not be colsed in this way.

Rgds,
Frodo
0
 
LVL 2

Expert Comment

by:FrodoBeggins
ID: 6311883
Anyway, no matter the way your application is closed, all the resources will be freed (by Windows). Only if you need to do some specific cleanup there may be a problem

Rgds,
Frodo
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 5

Expert Comment

by:Gwena
ID: 6314738
listening  :-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6321295
Hello, TomazB, are you already alive??
0
 

Author Comment

by:TomazB
ID: 6322671
Yes, Yes, sorry for delay. I was out of town for two days.
Thank's kretzschmar!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 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