JUCE applications don't respond WM_QUIT?


#1

Hi Jules,

I tried to terminate Juce Application from another application using WM_QUIT message, but the Juce Application doesn’t exit. I think it should exit when receives the WM_QUIT message.

In my Juce application, I set T(“MyJuceApp”) for my top level window.

In the “terminator” application, I do following.

void Test()
{
    //  works fine, I can terminate NotePad.exe with success.
    PostMessage(FindWindow(L"Notepad", NULL), WM_QUIT, 0, 0);

    // failed
    PostMessage(FindWindow(NULL, L"MyJuceApp"), WM_QUIT, 0, 0);

    // failed
    PostMessage(FindWindow(NULL, L"The Jucer"), WM_QUIT, 0, 0);
}

I have confirmed all those window handle is valid.

Best regards,
Masanao Hayashi


#2

Good point. It responds to WM_CLOSE, but I never made it handle WM_QUIT. It’s an easy one to add, though. I’ve checked in a new version now that should be ok.


#3

Shouldn’t the WM_QUIT handler be in the juce_dispatchNextMessageOnSystemQueue ? If I do a “::PostQuitMessage(0)” in a buttonClicked handler, nothing happens with the latest git juce. However, if I modify juce_dispatchNextMessageOnSystemQueue, it works as expected:

if (GetMessage (&m, (HWND) 0, 0, 0) >= 0)
{

  •  if (m.message == WM_QUIT) {
    
  •    if (JUCEApplication::getInstance()) {
    
  •      JUCEApplication::getInstance()->systemRequestedQuit();
    
  •    }
    
  •  }
    

(Note that I replaced the “>” by a “>=” since the msdn doc states that GetMessage returns 0 on wm_quit )


#4

oh, so WM_QUIT doesn’t get sent to a window. Ok, thanks, will figure something out…