🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: HELP: My app closes, but cancels Windows shutdown?

#2374
From: A Nonymous
Date: Thu, 08 Mar 2007 20:33
41 lines
2139 bytes
More info:

My original code which has not changed in a LONG time and used to work 
fine:

void __fastcall TFormMain::wmQueryEndSession(TMessage& Message)
{
  Message.Result = 1;
  SaveFile();
  CloseFile();
  Application->Terminate();
}

My fake shutdown app is just a form with a button and a memo.  The 
button press event looks like this:

void __fastcall TForm1::ButtonQueryEndSessionClick(TObject *Sender)
{
  Memo->Lines->Append("Send WM_QueryEndSession Message:");
  WPARAM wParam = 0;
  LPARAM lParam = 0;
  HWND H = FindWindow("TFormMain",NULL);
  if(H)
  {
    Memo->Lines->Append("- Application window handle = " + IntToStr(H));
    if (SendMessage(H,WM_QUERYENDSESSION,wParam,lParam))
      Memo->Lines->Append("- Application responded OK to close.");
    else
      Memo->Lines->Append("- Application responded NOT OK to close.");
    Memo->Lines->Append("- wParam = " + IntToStr(wParam));
    Memo->Lines->Append("- lParam = " + IntToStr(lParam));
  }
  else
    Memo->Lines->Append("- Application window handle NOT FOUND!");
  Memo->Lines->Append("----------------------------------");
}

The send message return is true, and both wParam and lParam are 0.  My 
application is saving and closing it's files.

OK, so why doesn't windows shutdown?
Technical Details
Message-ID: <Xns98ED941B2E2C8anonymoushotmailcom@207.105.83.66>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!tudelft.nl!txtfeed1.tudelft.nl!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <Xns98ED90968E734anonymoushotmailcom@207.105.83.66>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,346f60f70c29a156
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: HELP: My app closes, but cancels Windows shutdown?
From: A Nonymous <anonymous@hotmail.com>
References: <Xns98ED90968E734anonymoushotmailcom@207.105.83.66>
Message-ID: <Xns98ED941B2E2C8anonymoushotmailcom@207.105.83.66>
User-Agent: Xnews/5.04.25
NNTP-Posting-Host: 74.254.162.162
Date: 8 Mar 2007 12:33:02 -0800
X-Trace: newsgroups.borland.com 1173385982 74.254.162.162 (8 Mar 2007 12:33:02 -0800)
Lines: 41
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!tudelft.nl!txtfeed1.tudelft.nl!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail