Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your message loop fetches, and dispatches, messages for all windows created on the current thread.</p> <p>A simple message loop like this will suffice.</p> <pre><code>MSG msg; while(GetMessage(&amp;msg,0,0,0,0)&gt;0) { TranslateMessage(&amp;msg); DispatchMessage(&amp;msg); } </code></pre> <p>Otherwise, to create windows on the thread, you simply call CreateWindow(...) as often as you want/need to build your UI.</p> <p>Warning: A common pattern seen in many simple programs is to handle <code>WM_DESTROY</code> in a WindowProc to call PostQuitMessage(). PostQuitMessage() posts a message to the thread, telling the message loop to exit. This will terminate the app, destroying <em>all</em> the windows on the thread. If you have a main application window that, if closed, should exit the app, only that window should call PostQuitMessage. If you have two (or more) windows that can be closed in any sequence, then you need to maintain a count of open windows and call PostQuitMessage only when the last window is closed by the user.</p> <p>Really, any sample program that demonstrates a dialog box is ALSO demonstrating how to create many windows on a thread, as every control on a dialog box IS also a window with a windowproc.</p> <p>Many new Windows developers fall into a trap of trying to filter messages for a specific window:</p> <pre><code> while(GetMessage(&amp;msg,hwnd,0,0,0)... </code></pre> <p>This is wrong as it prevents any child windows getting their messages. Lots of utilitie libraries will create hidden windows on a thread and use them to receive messages from other processes / threads - filtering only messages for the app window like that will cause the message queue to grow, and other things to fail in strange an unusual ways. Pass NULL for the hwnd until you understand exactly why you might want to filter messages for a specific window for a while.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload