Click to See Complete Forum and Search --> : [RESOLVED] PostThreadMessage to specific window handler.


Lars_V_J
March 4th, 2009, 05:09 AM
In my main thread, I have a normal Postmessage:

::PostMessage(WSHandlerHNDL, KCS_POLLRCV_POSTMSG, (WPARAM)lpBuf, (LPARAM)buffer);

Now, I want to do the same thing with PostThreadMessage, but it doesn't have a HWND param. How do I do that?

Also...where does the PostThreadMessage messages end up? I have considered to go to the mainframe class and add a ON_THREAD_MESSAGE
that passes the message on to the right HWND, but I don't know if that's the right approach or if it can be done easier...

Thanks in advance

Codeplug
March 4th, 2009, 08:53 AM
>> Now, I want to do the same thing with PostThreadMessage
Why? If you need it to go to a specific window, then why not use PostMessage?

>> where does the PostThreadMessage messages end up?
It ends up in the message Q of the specified thread. However, the message is associated with a HWND of NULL.

You can just use PostMessage() to target an HWND of your process - even if it's on another thread.

gg

Lars_V_J
March 5th, 2009, 03:12 AM
Thank you for your fast response.

I had read somewhere that the PostMessage wasn't thread safe. I had misunderstood things so that all thread communication (also those that are not a CThread...whatever it was called - class) had to use PostThreadMessage. Needless to say, I got loads of compiler errors :-)