Re: Worker thread in VC++ 6
 
Scott McPhillips [MVP] wrote:
"Kahlua" <kahlua@right.here> wrote in message 
news:MaCuj.9627$eg3.7947@trndny05...
I still dont understand the PostMessage usage.
Joe's MVP tips page regarding PostMessage is so drawn out and full of 
"but your not done yet, now you need to do this" that I cant seem to 
follow it.
In the meantime I guess I will continue my google research on 
PostMessage to find a simpler usage explanation.
Thanks anyway.
Maybe this will help:
http://vcfaq.mvps.org/mfc/12.htm
Scott:
I just read this reference, and there are two things in it I don't agree with:
1. "Your secondary thread will need an hwnd (not a CWnd*) to post to."
This is not necessary. It is perfectly safe to call CWnd::PostMessage() or 
CWnd::SendMessage(). This is because these calls wrap ::PostMessage() and 
::SendMessage() in a very simple way.
2. "To receive and process the message in the main thread code, first declare 
your message hander function in the main window's h file. MFC does not route 
user-defined messages to views or docs, so the handler must be a member function 
of the CMainFrame class (or the main dialog class in a dialog-based app)."
This is also not necessary. Rather the handler must be in whatever class that 
you send or post the message to (need not be the class corresponding to the main 
window).
Otherwise the link is a good explanation of how to post or send private messages.
-- 
David Wilkinson
Visual C++ MVP