Jump to content
  • Advertisement
Sign in to follow this  
Yohomyth

message loop problem

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

Here's my message loop:
MSG msg;

for( ;; )
{
	if( PeekMessage( &msg, NULL, NULL, NULL, PM_REMOVE ) )
	{
		if( msg.message == WM_QUIT )
			return ( int ) msg.wparam;
		else
		{
			TranslateMessage( &msg );
			DispatchMessage( &msg );
		}
	}
	else Idle( );
}
I think I'm probably using PeekMessage incorrectly. it always returns TRUE so i never get a call to Idle().

Share this post


Link to post
Share on other sites
Advertisement
I believe the third and fourth parameters to PeekMessage should specify a range of messages... you may want to set the fourth parameter to (UINT)-1

Here's a message pump with "GetMessage"


while (::GetMessage(&_message, NULL, 0, 0)){
if (!::TranslateAccelerator(hwnd,hAccelTable, &_message))
{
::TranslateMessage(&_message);
::DispatchMessage(&_message);
}
}
return _message.wParam;



[EDIT TO ADD] You may also want the window handle (HWND); a NULL handle works for GetMessage, but the docs on PeekMessage don't mention that.

Share this post


Link to post
Share on other sites
Hmm.. this is really a weird problem, I'm using the same code and here it works fine. I can only suggest you to debug the program and check what messages he always gets (msg.message). And maybe there is some message that you don't process correctly so he keeps sending it until you do.

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!