title: How to intercept a message: "WM_QUIT || WM_DESTROY || WM_CLOSE" WinAPI
body: <p>I use this code for the main loop (my function):</p>
  
  <pre><code>    while (running)
  {
      if(is_close)
      {
          Log().push_log("close", "message close!", logInfo);
          running = active = false;
  
          break;
      }
  
      while (PeekMessage(&amp;msg, g_hWnd, 0, 0, PM_REMOVE))
      {
          std::cout &lt;&lt; "Wnd: " &lt;&lt; msg.message &lt;&lt; std::endl;
  
          if (msg.message == WM_QUIT || msg.message == WM_DESTROY || msg.message == WM_CLOSE)
          {
              MessageBox(0, "Hello, World", "Hello", MB_OK);
              running = false;
          }
          // TranslateMessage(&amp;msg);
          DispatchMessage(&amp;msg);
      }
  
      if (running &amp;&amp; active)
          render.DrawObject(g_hDC);
  }
  </code></pre>
  
  <p>Well, then I use WndProc:</p>
  
  <pre><code>LRESULT CALLBACK GLWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  {
      std::cout &lt;&lt; "Wnd Proc: " &lt;&lt; msg &lt;&lt; std::endl;
  
      return DefWindowProc(hWnd, msg, wParam, lParam);
  }
  </code></pre>
  
  <p>When I'm trying to get the message <code>WM_QUIT</code>, <code>WM_DESTROY</code>, or <code>WM_CLOSE</code> in my function, it does not work. My function does not see messages.</p>
  
  <p>How can I get this message?</p>