🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10631

WM_QUERYENDSESSION problems

#10631
From: Brad
Date: Tue, 06 Apr 2004 02:48
38 lines
1997 bytes
Hi,

I'm trying to execute some code in my program if it's still open before Windows shuts down.

I've can trap WM_QUERYENDSESSION without a problem:

void __fastcall TWindow::NewWindowWP(TMessage &Message) {
  ...
  case WM_QUERYENDSESSION: {
    if (!EndSession) {
      Message.Result = false;
      EndSession = true;
      Close();
    }
    break;
  }
  ...
}

This momentarily stops Windows from shutting down. EndSession is a global bool. What I'm trying to do in WindowClose() is - after having executing the code I wanted - see if EndSession = true, and then call ExitWindows (or whatever) from there and then Windows will continue to shutdown:

void __fastcall TWindow::WindowClose(TObject *Sender, TCloseAction &Action) {

  // Code to execute goes here.
  
  if (EndSession) {
    // Shut down windows
  }
}

The problem is, EndSession is still false, even though I've tested that it has been set to true in NewWindowWP() above (and WindowClose() is called from there).

Am I missing something entirely? Am I not clear in what I'm trying to do? Ah, ... both?

Thanks in advance.

Brad.
Technical Details
Message-ID: <40720c60$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,3d57c832ecbfbde9,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-04-05 19:09:40 PST
From: "Brad" <bradhar@nospam.optusnet.com.au>
Sender: "Brad" <bradhar@nospam.optusnet.com.au>
Reply-To: "Brad" <bradhar@nospam.optusnet.com.au>
Subject: WM_QUERYENDSESSION problems
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 211.29.5.134     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <40720c60$1@newsgroups.borland.com>
Date: 5 Apr 2004 18:48:16 -0800
X-Trace: newsgroups.borland.com 1081216096 207.105.83.66 (5 Apr 2004 18:48:16 -0800)
Lines: 38
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail