Terminating application - preventing

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.).  
TomazBAsked:
Who is Participating?
 
kretzschmarConnect With a Mentor Commented:
just fill out the onclosequery-event

as long it is not allowed,
set there the canclose-var to false
0
 
FrodoBegginsCommented:
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
 
FrodoBegginsCommented:
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 
GwenaCommented:
listening  :-)
0
 
kretzschmarCommented:
Hello, TomazB, are you already alive??
0
 
TomazBAuthor Commented:
Yes, Yes, sorry for delay. I was out of town for two days.
Thank's kretzschmar!
0
All Courses

From novice to tech pro — start learning today.