How can I check for messages or "key presses" while in a loop?
Hello,
I'm writing a grapihcs program in MFC that runs though and does a little demo, but the user need to be able to stop the loop via hitting a key or something along those lines at any time. Any ideas? Is there some kind of API call to check for key msgs? I'm sure this is a common problem. Thank You! Rich Taylor
Re: How can I check for messages or "key presses" while in a loop?
Write yourself a little function like this:
void ProcessMessages()
{
for (MSG msg; ::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); )
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
}
And call it inside your loop.
Re: How can I check for messages or "key presses" while in a loop?