Solved

Disable Closing application...

Posted on 1997-11-11
4
208 Views
Last Modified: 2012-05-04
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
0
Comment
Question by:mories
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
Pegasus100397 earned 150 total points
ID: 1349944
Mories,

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

Good luck with your project!
Pegasus
0
 
LVL 1

Author Comment

by:mories
ID: 1349945
thank you very much, for the quick answer...
0
 
LVL 1

Author Comment

by:mories
ID: 1349946
the cross disappears, but pressing alt-f4 on the keyboard still close the app..
0
 
LVL 3

Expert Comment

by:Pegasus100397
ID: 1349947
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);
begin
Msg.Result := 0;   {If you want the app to ignore the close command}

* or *

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

Good luck with your project!
Pegasus
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now