mikehui
asked on
PostThreadMessage and PeekMessage
I've written the code using VC++5.0 in WinNT as follow:
...
void main() {
...
ft = (HANDLE) _beginthreadex(NULL, sz, POne, 0, 0,(unsigned int*) &dft);
r = PostThreadMessage(dft, WM_NULL, 0,0);
Sleep(5000);
...
}
void POne() {
...
MG msg;
for(;;) {
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
(
printf("Message Received!\n");
break;
}
WaitMessage();
}
...
}
In running the above code, the 'Message Received' does not prompt. But it work on Win95 successfully. I've no idea about this problem. Does any suggestion or advice for me?
Thank you for your attention.
Regards,
Michael
...
void main() {
...
ft = (HANDLE) _beginthreadex(NULL, sz, POne, 0, 0,(unsigned int*) &dft);
r = PostThreadMessage(dft, WM_NULL, 0,0);
Sleep(5000);
...
}
void POne() {
...
MG msg;
for(;;) {
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
(
printf("Message Received!\n");
break;
}
WaitMessage();
}
...
}
In running the above code, the 'Message Received' does not prompt. But it work on Win95 successfully. I've no idea about this problem. Does any suggestion or advice for me?
Thank you for your attention.
Regards,
Michael
What messages should it be geting? probably none. You might try using AttachThreadInput() so that it gets some of the input messages that would be going to the main thread.
What is it that you are trying to do?
What is it that you are trying to do?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Does any time interval required in a sequence of PostThreadMessage function call?
Do you mean 'Is there a time interval required between calls to PostThreadMessage'.
No, the Threads Message Queue will continue to accept messages as fast as you can post them, however, you should check the return from PostThreadMessage, since it can sometimes fail - for reasons unclear -
No, the Threads Message Queue will continue to accept messages as fast as you can post them, however, you should check the return from PostThreadMessage, since it can sometimes fail - for reasons unclear -
ASKER