Solved

Program Onclosing.

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
APK file name 7 64
TcomboBox uninverted item 3 45
Delphi cmd execution 6 40
Adoquery sql  left join does not work 25 49
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…
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…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 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

18 Experts available now in Live!

Get 1:1 Help Now