johnsla
asked on
Designing a well behaved MFC dialog app
OK. What am I doing wrong. Why is it when I create an MFC app that is performing a process I cannot move the dialog box, repaint the screen when another app gets the focus and covers mine, or get the Cancel key to kill the app. There must be some polling issue I'm missing and should implement.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Assuming that the Peek/Translate/DispatchMes sage construct does work, you have to put it inside your process, so that it gets executed every now and then (how often depends on how quickly the application should respond). So for example, if you are performing a lengthly calculation in a loop, you have to execute this code inside your processing loop:
while (!done)
{
if (counter % 1000 == 0)
{
while (::PeekMessage((&msg, NULL, NULL, NULL, PM_REMOVE)
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
// do your calculation
...
}
}
If this still does not work, take a look at the link that I posted earlier. The threaded approach should work regardless of what you do in your worker process.
while (!done)
{
if (counter % 1000 == 0)
{
while (::PeekMessage((&msg, NULL, NULL, NULL, PM_REMOVE)
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
// do your calculation
...
}
}
If this still does not work, take a look at the link that I posted earlier. The threaded approach should work regardless of what you do in your worker process.
I provided at least part of the solution.
ASKER