Solved

Program Onclosing.

Posted on 2003-11-07
3
144 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

679 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