I'm having some trouble with the windows message loop. The trouble is, when I use GetMessage I have to wait for a windows message for it to return, which means I can't update graphics on the screen in the main message loop unless there is a windows message. Then I have to use WM_TIMER which doesn't go fast enough.
If I use PeekMessage the program runs fine except it hardly ever gets windows messages. Meaning it doesn't react well at all. If I try and click on the file menu on my prog, it takes like 10 seconds to come up. I have to use ctrl-alt-del to close it. I'll post the two I've tried:
Code:
/*while( (bRet = GetMessage( &Msg, NULL, 0, 0 )) != 0)
{
if (bRet == -1)
{
PostQuitMessage(0);
}
else
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
MainFunc(hWnd);
}*/
Code:
while(!done)
{
if(PeekMessage(&Msg, hWnd, 0, 0, PM_REMOVE))
{
if(Msg.message == WM_QUIT)
done = true;
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
MainFunc(hWnd);
}