Does anyone know how to implemented a loop in a dialog procedure which will
stop when the user presses a button via the mouse? In a dialog I have a long
job to process or sometimes to wait for an external signal via I/O. I want
the user to be able to interrupt the waiting loop.
I have tried the following:
static int condition;
case ID_RUN: // Run button pressed
if (condition) break;
PostMessage(hDlg,WM_COMMAND,ID_RUN,0L); // initiate next round
condition = TRUE;
The idea here is to let the loop through the Windows message translation
so the message of the CANCEL button can be processed, and the loop broken.
However, Windows seems never to process the ID_CANCEL message and the program
hangs in the endless loop of processing and re-processing ID_RUN. It
appeared that the message posted by PostMessage always gets through the message
loop first, before any user inputs.
Any suggestions welcome.
Thanks in advance