我的代码如下:
BOOL CMOThread::PreTranslateMessage(MSG* pMsg) 
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_SERVER_ACCEPT)
{
AfxMessageBox("dd");
return TRUE;
}
return CWinThread::PreTranslateMessage(pMsg);
}在主线程中这样发消息:
CMOThread *myMO; 
PostThreadMessage(myMO->MyThreadID,WM_SERVER_ACCEPT,wParam,lParam);

解决方案 »

  1.   

    在接收线程中有没有一个用来PeekMessage或GetMessage的代码?
      

  2.   

    其他部分都是默认的,我也没重载RUN, CYBER您能告诉我怎么做吗?
      

  3.   

    在你的工作线程中也要用PeekMessage或GetMessage加入消息循环。

    while (GetMessage(...))
    {
    }
      

  4.   

    在你的工作线程中写下列代码
    #define WM_YOURMS  WM_USER + 100
    UINT YourWorkThread(LPVOID lpParameter)
    {}
      

  5.   

    在你的工作线程中写下列代码
    #define WM_YOURMS  WM_USER + 100
    UINT YourWorkThread(LPVOID lpParameter)
    {
      MSG msg;
     while(PeekMessage(&msg,NULL, WM_USER, WM_USER, PM_NOREMOVE ))
    {
      if(msg.message == WM_YOURMS)
       {
          do something here
          return 0;
       }
     }
     return 1;
    }
    这样产生的消息队列默认只能接受10000个消息,而且不能调用DISPATCHMESSG函数,
    如果你要重复接受消息,建议使用UI线程