Jump to content
  • Advertisement
Sign in to follow this  
lonewolff

Win32 Problem with wm_command message

This topic is 781 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

Seems I needed to DestroyWindow(hWnd) instead of PostQuitMessage(0) at that call.

 

All working ok now.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!