If MessageBox()/related are synchronous, why doesn't my message loop freeze?
Why is it that if I call a seemingly synchronous Windows function like MessageBox() inside of my message loop, the loop itself doesn't freeze as if I called Sleep() (or a similar function) instead? To illustrate my point, take the following skeletal WndProc : int counter = 0; LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CREATE: SetTimer(hwnd, 1, 1000, NULL); //start a 1 second timer break; case WM_PAINT: // paint/display counter variable onto window break; case WM_TIMER: //occurs every second counter++; InvalidateRect(hwnd, NULL, TRUE); /