Solved

Disable Closing application...

Posted on 1997-11-11
4
223 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

810 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