lsvedin
December 16th, 2004, 04:34 PM
I really hate being a bother, but here's the problem. I have two threads up and running, a main and a worker. I am only passing data between them using PostThreadMessage.
The main thread kick off the worker thread class and then the main thread pops up a modal dialog box. The dialog box does a POSTTHREADMESSAGE to the worker thread, the thread does its thing, and then it does a POSTTHREADMESSAGE back to the main thread. Here comes in the problem, the main thread does a POSTMESSAGE to the dialog and the app does all sorts of funny things.
Looking in the debugger, the call stack has this
CWnd::PostMessageA(unsigned int 1039, unsigned int 16387, long 0) line 41 + 43 bytes
MyApp::SendToMyDialog(unsigned int 16387, long 0) line 347
CWinThread::DispatchThreadMessageEx(tagMSG * 0x0042d1f8 {msg=0x0000040f wp=0x00004003 lp=0x00000000}) line 652
CWinThread::PreTranslateMessage(tagMSG * 0x0042d1f8 {msg=0x0000040f wp=0x00004003 lp=0x00000000}) line 660 + 20 bytes
CWinThread::PumpMessage() line 841 + 30 bytes
CWnd::RunModalLoop(unsigned long 4) line 3478 + 19 bytes
CDialog::DoModal() line 536 + 12 bytes
MyView::DoThat(unsigned int 1031) line 649 + 11 bytes
MyApp::DoThis(unsigned int 0, long 0) line 307
It appears that the dialog is running in its own thread and so I believe that I can't do a myDlg->PostMessage() since its a CWnd function.
I tried a ::PostMessage(myDlg.m_hwnd, data1, data2), but the handle was NULL and I tried a GetSafeHwnd, but that returned a NULL.
Will the latter solve the problem if I get a valid handle and if so, how do I get a valid handle?
The main thread kick off the worker thread class and then the main thread pops up a modal dialog box. The dialog box does a POSTTHREADMESSAGE to the worker thread, the thread does its thing, and then it does a POSTTHREADMESSAGE back to the main thread. Here comes in the problem, the main thread does a POSTMESSAGE to the dialog and the app does all sorts of funny things.
Looking in the debugger, the call stack has this
CWnd::PostMessageA(unsigned int 1039, unsigned int 16387, long 0) line 41 + 43 bytes
MyApp::SendToMyDialog(unsigned int 16387, long 0) line 347
CWinThread::DispatchThreadMessageEx(tagMSG * 0x0042d1f8 {msg=0x0000040f wp=0x00004003 lp=0x00000000}) line 652
CWinThread::PreTranslateMessage(tagMSG * 0x0042d1f8 {msg=0x0000040f wp=0x00004003 lp=0x00000000}) line 660 + 20 bytes
CWinThread::PumpMessage() line 841 + 30 bytes
CWnd::RunModalLoop(unsigned long 4) line 3478 + 19 bytes
CDialog::DoModal() line 536 + 12 bytes
MyView::DoThat(unsigned int 1031) line 649 + 11 bytes
MyApp::DoThis(unsigned int 0, long 0) line 307
It appears that the dialog is running in its own thread and so I believe that I can't do a myDlg->PostMessage() since its a CWnd function.
I tried a ::PostMessage(myDlg.m_hwnd, data1, data2), but the handle was NULL and I tried a GetSafeHwnd, but that returned a NULL.
Will the latter solve the problem if I get a valid handle and if so, how do I get a valid handle?