Click to See Complete Forum and Search --> : How can I check for messages or "key presses" while in a loop?


June 10th, 1999, 04:15 PM
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

ALM
June 10th, 1999, 04:26 PM
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.

June 10th, 1999, 04:52 PM
Thank You!