title: Wait for a window message for a defined time
body: <p>I am programming with winapi. How do I wait for a message for a defined time?
  If there is no message, I can do another task. I can not use Sleep, because the window callback procedure will be delayed.</p>
  
  <pre><code>while (true){
      ...//wait a message for 30 miliseconds
      GetMessage(&amp;message, hwnd, 0, 0) ) or PeekMessage(&amp;message, hwnd, 0, 0, PM_REMOVE)
      ...
      if ( no_message ){
          call_a_function();
      } else {
          if (finish)
              break;
          TranslateMessage(&amp;message);
          DispatchMessage(&amp;message);
          ...//set to wait 30 minus elapsed time 
      }
  }
  </code></pre>