Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. WM_QUERYENDSESSION problem on C++ Builder 2010

WM_QUERYENDSESSION problem on C++ Builder 2010

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++tutorialquestion
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 888993
    wrote on last edited by
    #1

    I have the following code: .... private: void __fastcall WMQueryEndSession(TWMQueryEndSession& Message); BEGIN_MESSAGE_MAP MESSAGE_HANDLER(WM_QUERYENDSESSION, TWMQueryEndSession, WMQueryEndSession) END_MESSAGE_MAP(TForm) ..... void __fastcall TForm1::WMQueryEndSession(TWMQueryEndSession & Message) { Message.Result=0; } Compiled by C++ Builder 2010, the code works improperly. Although it prevents the computer from shut down, but it also closes my application. The code below fixes the problem, but it is not stable (sometimes does not work) and the such long delay in 10 seconds is not acceptable in my case: void __fastcall TForm1::WMQueryEndSession(TWMQueryEndSession& Message) { Sleep(10000); Message.Result=0; } Does enybody know how to fix the problem? Thanks.

    A 1 Reply Last reply
    0
    • U User 888993

      I have the following code: .... private: void __fastcall WMQueryEndSession(TWMQueryEndSession& Message); BEGIN_MESSAGE_MAP MESSAGE_HANDLER(WM_QUERYENDSESSION, TWMQueryEndSession, WMQueryEndSession) END_MESSAGE_MAP(TForm) ..... void __fastcall TForm1::WMQueryEndSession(TWMQueryEndSession & Message) { Message.Result=0; } Compiled by C++ Builder 2010, the code works improperly. Although it prevents the computer from shut down, but it also closes my application. The code below fixes the problem, but it is not stable (sometimes does not work) and the such long delay in 10 seconds is not acceptable in my case: void __fastcall TForm1::WMQueryEndSession(TWMQueryEndSession& Message) { Sleep(10000); Message.Result=0; } Does enybody know how to fix the problem? Thanks.

      A Offline
      A Offline
      ARopo
      wrote on last edited by
      #2

      I had a simular problem and had to check for 2 messages WM_ENDSESSION or WM_QUERYENDSESSION. Then set a flag to indicate shutdown, this flag was then used in an OnClosing event that by default cancelled the close to minimize to the system tray

      U 1 Reply Last reply
      0
      • A ARopo

        I had a simular problem and had to check for 2 messages WM_ENDSESSION or WM_QUERYENDSESSION. Then set a flag to indicate shutdown, this flag was then used in an OnClosing event that by default cancelled the close to minimize to the system tray

        U Offline
        U Offline
        User 888993
        wrote on last edited by
        #3

        ARopo wrote:

        I had a simular problem and had to check for 2 messages WM_ENDSESSION or WM_QUERYENDSESSION. Then set a flag to indicate shutdown, this flag was then used in an OnClosing event that by default cancelled the close to minimize to the system tray

        Thank you for your answer. Hovewer your suggestion will not work in my case as WM_ENDSESSION is calling Application->Termiante() which terminates program even if the flag in OnClose event is set to hide or none and the application is minimized to the systray. Calling Application->Termiante() by WM_ENDSESSION (even if application returns zero to WM_QUERYENDSESSION message) is recent bug of C++ Builder 2010. Previous versions of the compiler worked properly and did not call Application->Termiante() if application returned zero to WM_QUERYENDSESSION message. Does anybody know how to fix or bypass this bug of the C++ Builder 2010?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups