• Advertisement
Sign in to follow this  

Win32 Problem with wm_command message

This topic is 697 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys,

 

I am trying to figure out why my message handler isn't working properly.

 

If I click File and then Exit, I get the pop-up box as expected, but my program will not exit. Closing the window will exit correctly however.

LRESULT CALLBACK Editor::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
		case WM_COMMAND:
			switch (LOWORD(wParam))
			{
				case ID_FILE_OPEN:
				{
				}
				break;

				case ID_FILE_SAVE:
				{
				}
				break;
			
				case ID_FILE_EXIT:
				{
					MessageBox(NULL, L"File/Exit is being detected", L"Test", NULL);
					PostQuitMessage(0);
				}
				break;
				default:
					return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;

		case WM_DESTROY:
			PostQuitMessage(0);
			//return 0;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
}

WM_DESTROY is working correctly. But ID_FILE_EXIT isn't. The message box pops up, as per the code, but the program wont exit.

 

Any advice on what I am overlooking would be hugely appreciated.

 

Thanks in advance :)

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement