Click here to Skip to main content
15,913,487 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: URGENT - Please Help! Pin
Masaaki Onishi30-Mar-01 6:45
Masaaki Onishi30-Mar-01 6:45 
GeneralWarnings compiling STL Pin
30-Mar-01 3:05
suss30-Mar-01 3:05 
GeneralRe: Warnings compiling STL Pin
Chris Losinger30-Mar-01 3:44
professionalChris Losinger30-Mar-01 3:44 
GeneralRe: Warnings compiling STL Pin
Anders Molin31-Mar-01 6:59
professionalAnders Molin31-Mar-01 6:59 
Generalsending messages from a worker thread to cdocument Pin
derhackler29-Mar-01 23:17
derhackler29-Mar-01 23:17 
GeneralRe: sending messages from a worker thread to cdocument Pin
markkuk30-Mar-01 0:09
markkuk30-Mar-01 0:09 
GeneralRe: sending messages from a worker thread to cdocument Pin
derhackler30-Mar-01 0:54
derhackler30-Mar-01 0:54 
GeneralRe: sending messages from a worker thread to cdocument Pin
BenDev30-Mar-01 3:03
BenDev30-Mar-01 3:03 
The AfxGetMainWnd() will return the main window of the thread that made the call and it's not likely to be to one you want it receive the message.

Furthermore, you should avoid using MFC objects in your thread if they have been created in another thread. MFC doesn't handle that very well...

My prefered solution is to pass the HWND you need to your thread as a parameter :

CWinThread* pThread = AfxBeginThread(MyThread, (HWND)m_hWnd); // or any HWND you want

UINT MyThread(LPVOID pParam)
{
HWND hWnd = (HWND)pParam;
::PostMessage(hWnd, ...
}

You can pass a CWnd* as well but remember you want be able to access all its methods. In your case, if you only want to do a pWnd->PostMessage(...), it will work.

-------------------------
Benoit Devigne
http://www.bdevigne.com
contact@bdevigne.com
GeneralRe: sending messages from a worker thread to cdocument Pin
Ajit Jadhav30-Mar-01 6:47
Ajit Jadhav30-Mar-01 6:47 
GeneralRe: sending messages from a worker thread to cdocument Pin
derhackler30-Mar-01 6:50
derhackler30-Mar-01 6:50 
GeneralRe: sending messages from a worker thread to cdocument Pin
Ajit Jadhav30-Mar-01 7:19
Ajit Jadhav30-Mar-01 7:19 
GeneralRe: sending messages from a worker thread to cdocument Pin
derhackler30-Mar-01 8:50
derhackler30-Mar-01 8:50 
GeneralRe: sending messages from a worker thread to cdocument Pin
Ajit Jadhav31-Mar-01 12:42
Ajit Jadhav31-Mar-01 12:42 
GeneralRe: sending messages from a worker thread to cdocument Pin
Ajit Jadhav31-Mar-01 15:45
Ajit Jadhav31-Mar-01 15:45 
GeneralRe: sending messages from a worker thread to cdocument Pin
derhackler2-Apr-01 4:08
derhackler2-Apr-01 4:08 
GeneralRe: sending messages from a worker thread to cdocument Pin
30-Mar-01 3:18
suss30-Mar-01 3:18 
GeneralRe: sending messages from a worker thread to cdocument Pin
derhackler30-Mar-01 6:53
derhackler30-Mar-01 6:53 
GeneralShortcuts on desktop and groups... Pin
29-Mar-01 22:07
suss29-Mar-01 22:07 
GeneralRe: Shortcuts on desktop and groups... Pin
Erik Thompson30-Mar-01 9:01
sitebuilderErik Thompson30-Mar-01 9:01 
GeneralGetting a handle to a resource Pin
Jared Allen29-Mar-01 20:12
Jared Allen29-Mar-01 20:12 
Generalowner-draw combo-box Pin
Bruno Vais29-Mar-01 11:17
Bruno Vais29-Mar-01 11:17 
Questionwhat are threads and processes Pin
29-Mar-01 8:40
suss29-Mar-01 8:40 
AnswerRe: what are threads and processes Pin
Wayne Fuller29-Mar-01 8:59
Wayne Fuller29-Mar-01 8:59 
GeneralRe: what are threads and processes Pin
29-Mar-01 9:24
suss29-Mar-01 9:24 
GeneralRe: what are threads and processes Pin
Scott!29-Mar-01 9:48
Scott!29-Mar-01 9:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.