I tried to test the "Examining a Message Queue" example in this page:
http://msdn.microsoft.com/en-us/library/ms644928(VS.85).aspx
In order to test it I created a simple window with an edit control and some buttons,
but it doesn't work as I expected, It should Display repeatedly the string "Some Text" in the EditControl until
I press a button... but the problem is that It displays the string only the first time and then it seems to block in the PeekMessage loop.
I noticed that placing a DispatchMessage(&msg) call afterward, it seems to work properly.
How can I resolve??? Do I necessarily have to call DispatchMessage(&msg)???
Thanks!
HWND hwnd; BOOL fDone; MSG msg; fDone = FALSE; while (!fDone) { SetFocus(EditControl); SendMessage(EditControl, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)TEXT("Some Text\r\n")); while (PeekMessage(&msg, hwnd, 0, 0, PM_REMOVE)) // It blocks here, if I press any button it always sets fDone to TRUE without exiting the loop { // DispatchMessage(&msg); uncomment this and it works switch(msg.message) { case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_KEYDOWN: { fDone = TRUE; SetFocus(EditControl); SendMessage(EditControl, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)TEXT("fDone set to TRUE\r\n")); } } } }