Board index » delphi » WM_QUERYENDSESSION and WM_ENDSESSION problem

WM_QUERYENDSESSION and WM_ENDSESSION problem

I've an application written in Delphi 1.02 that won't close when the user
tries to shutdown Windows.

I've set up a test where my application is the only one running when the
user tries to shutdown.  I've trapped the WM_QUERYENDSESSION that is sent
to my app's main form and checked that a non-zero (i.e. '1') value is
returned:  

procedure TMyForm.WMQueryEndSession(var aMessage: TWMQueryEndSession );
begin
 { disbable any local timers }
   MyTimer.Enabled := false;
 { pass message onto superclass for further processing}
   inherited;
 { this message box always shows message result to be set to 1 after call
to superclass}
ShowMessage('called inherited WMQueryEndSession, result = ' +
IntToStr(aMessage.Result));
end;

I then trap the WM_ENDSESSION message that is broadcast but its wParam
parameter is always set to FALSE so my application insn't closed down nor
is Windows.  Does anybody know why this could be happening?  

My application is the only one that is running.  I had thought that perhaps
TTimer objects which were still enabled in my app could be causing the
problem so they are all disabled in the WMQueryEndSession method but this
doesn't help.  Could any DLLs that are loaded prevent Windows from closing
down?

Thanks

--
Andrew Jackson
ajack...@cccgroup.co.uk

 

Re:WM_QUERYENDSESSION and WM_ENDSESSION problem


Andrew Jackson <ajack...@cccgroup.co.uk> D?? ???
<01bc7582$0e635380$f60170c1@jalfrezi>...

Quote
> I've an application written in Delphi 1.02 that won't close when the user
> tries to shutdown Windows.

That's known bug in Delphi 1.0 VCL, use this method:

    function WindowHook(var Message: TMessage): Boolean;

..FormCreate(Sender: TObject);
  Application.HookMainWindow(WindowHook);

..WindowHook;
begin
  Result := False;

  with Message do
    case Msg of
      WM_ENDSESSION:
        if TWMEndSession(Message).EndSession then
          Halt{FROM: hallv...@falcon.no (Hallvard Vassbotn)};

--
Alexander Petrosyan, Moscow.
email: p...@i-connect.ru, p...@fbit.msk.su
phone: +7(095)535-2222

Re:WM_QUERYENDSESSION and WM_ENDSESSION problem


I've had the same probelem in my app.
It turned out to be incorrectly written components it used. In short
some non-visual components used a hidden window to process mesages and
didn't bother to call DefWindowProc .
If that is the problem, you'll have to isolate those components and
fix them.

hope this helps,

Vadim

Quote
"Andrew Jackson" <ajack...@cccgroup.co.uk> wrote:
>I've an application written in Delphi 1.02 that won't close when the user
>tries to shutdown Windows.

>I've set up a test where my application is the only one running when the
>user tries to shutdown.  I've trapped the WM_QUERYENDSESSION that is sent
>to my app's main form and checked that a non-zero (i.e. '1') value is
>returned:  

[deleted]
Quote
>My application is the only one that is running.  I had thought that perhaps
>TTimer objects which were still enabled in my app could be causing the
>problem so they are all disabled in the WMQueryEndSession method but this
>doesn't help.  Could any DLLs that are loaded prevent Windows from closing
>down?

>Thanks
>Andrew Jackson
>ajack...@cccgroup.co.uk

Other Threads