Solved

Program Onclosing.

Posted on 2003-11-07
3
143 Views
Last Modified: 2010-05-18
Hey.

The program onclose event works when i close the program.
But when windows closes it or taskmanager then it won't use the onclose event.
How can you set an event on windows closes or taskmanager.

Thanks.
0
Comment
Question by:JuiceJJ
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
geobul earned 125 total points
ID: 9701960
Hi,

About Windows shutdown:

type
  TForm1 = class(TForm)
  private
    { Private declarations }
    procedure WMQueryEndSession (var Message: TMessage); message WM_QUERYENDSESSION ;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.WMQueryEndSession(var Message: TMessage);
begin
  // do your stuff here
  Message.Result := Integer(true);
end;

Regards, Geo
0
 
LVL 17

Expert Comment

by:geobul
ID: 9701993
Forgot to say that TForm1 is your main form. The code above is for your main form only.

When I close an app with the Task manager (Windows XP) then my form's OnClose event gets called.

Regards, Geo
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 9702152
why don't use the OnCloseQuery event?
It's called when message WMQueryEndSession is received by the form...
and there you can also reject the closure setting canclose to false

F68 ;-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

809 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