Original Post
I was just workin on some Win32 programming and was setting up the window when I used the function PeekMessage with the parameters: PeekMessage(&Msg, hWnd, 0, 0, PM_REMOVE); From what I've seen this should work ok for my one window application. But I started having problems with the program quitting correctly. When I would click on the close button (the default upper right one) the window would not do anything. I then looked at it with Spy++ and saw that once i clicked the button, WM_CLOSE was passed. My WM_CASE switch was set at: case WM_CLOSE: PostQuitMessage(0); break; But this didn't seem to execute. I tried changing the line of PeekMessage to: PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE); And this seemed to fix it. Now it works correctly. I can go ahead and use this method since it will work better once I start adding child windows anyway, but I want to know why changing the HWND parameter to NULL should matter if my window only had the one HWND instance anyway. So know matter what I did in that window, it should have been handled in my WindowProc function. Does anybody know why that it didn't work?