Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Disable Closing application...

Posted on 1997-11-11
4
Medium Priority
?
255 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 600 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

885 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