|
-
November 3rd, 2005, 10:36 AM
#1
MsgWaitForMultipleObjects()
I give up!
I have tried everything to try and handle this function inside a modeless dialog box callback function (maybe that's not possible)?
Here is the code. Its in a radio button case statement.
Code:
if(wParam == RADIO_TIMER_TO_SIGNAL)
{
teststate = 5;
transceiver->SetDetectOnly(2, SIGNAL); // Set to look for a signal
hevent[0] = transceiver->GetEventHandle(2);
while((MsgWaitForMultipleObjects(1, hevent,
FALSE, INFINTE, QS_ALLINPUT)) != WAIT_OBJECT_0)
{
DSCMain->WriteText("M", 1); // diagnostic printout of "M"
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
DSCMain->WriteText("W", 1); // diagnostic printout of "W"
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
DSCMain->WriteText("F", 1); // diagnostic printout of "F"
transceiver->SetDetectOnly(2, NORMAL);
RedrawRadioButton(&radio_testsignal, RADIO_TESTOFF);
EnableWindow(GetDlgItem(hwindow, RADIO_TIMER_TO_SIGNAL), FALSE);
teststate = 0;
}
What the code does is wait for a radio signal to appear. Now if that happens, everything works fine; the wait function is signalled and the while loop ends and I get the "F" printed to a background window.
However, if I try to break the loop by user input, there is no way I can stop it. I have tried to identify a message addressed to the callback like WM_DESTROY, or WM_COMMAND with wParam IDCANCEL and have even been able to stop on these conditions in the debugger. Then I try to break the while loop. A 'break' command fails (the dialog box goes away but the while loop with the wait function remains and continues to print out the "M" diagnostic. I have tried to SetEvent(hevent[0]) and that fails. I have tried to change the timeout on the fly from infinite to 1 and that fails. I have tried calling the dialog callback function directly and that fails. The dialog box goes away if I call the Dispatch function but the "M's" continue to print.
The only way I have successfully been able to terminate that while loop with the MsgWaitFMO() function is by signalling the event from another thread.
How can I have the user break this loop if no signal decides to come?
Thanks,
Brian
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|