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().
message loop problem
Here's my message loop:
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"
[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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement