Disable Closing application...

Hello people,

how do make my program stop reacting on alt-f4 and the "cross".

i am writing a program for a network wich receives messages and the pop's up. i don't want my users to close the program
the mayonly hide it.

canclose := false in the CanClose event doesn't work then windows95 will not shutdown. since the program get's loaded every time the computer boots this is no good.

and i want the program to stop when it gets the message to reboot the system.

thanx for your time
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


on the MAIN form of the application, set biSystemMenu (under BorderIcons) to FALSE, this will disable closing.

Good luck with your project!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
moriesAuthor Commented:
thank you very much, for the quick answer...
moriesAuthor Commented:
the cross disappears, but pressing alt-f4 on the keyboard still close the app..
Oh ok! Sorry about missing the Alt-F4 part.

When the main form recieves the WM_CLOSE windows message it's "default" action is just to close the application (if the main form is showing). We need to inhibit this action by "handling" (ignoring) the WM_CLOSE message, thereby preventing the application from shutting down.

In the Private declarations section of the main form, let's declare the message handler:

procedure WMCLOSE(Var: TWMClose);
       Message WM_CLOSE;

now in the IMPLEMENTATION section let's put the actual code to handle the WM_CLOSE message:

procedure TForm1.WMCLOSE(Var Msg: TWMClose);
Msg.Result := 0;   {If you want the app to ignore the close command}

* or *

Form1.Close   {if you REALLY wanted to close it}

Good luck with your project!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.