在一个COM组件中,有一个CWnd窗口,在里面定义了自定义消息,但是在COM中无论是PostMessage还是SendMessage,该窗口都收不到这个消息。在外面使用这个CWnd类都是好用的,一放到COM中就收不到消息了。另外调用COM组件的是控制台程序,CWnd用如下方法创建:
另外我还试过ATL的Window模板类,也不能使用消息。WNDCLASSEX wndclass;
wndclass.cbSize=sizeof wndclass;
wndclass.style=0;
wndclass.lpfnWndProc=WindowProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=GetModuleHandle(0);
wndclass.hIcon=0;
wndclass.hCursor=0;
wndclass.hbrBackground=0;
wndclass.lpszMenuName=0;
wndclass.lpszClassName=_T("Helper Window");
wndclass.hIconSm=0;RegisterClassEx(&wndclass);
m_hWnd=CreateWindow(_T("Helper Window"), _T("Helper Window"), 0, 0, 0, 0, 0, 0, 0, 0, GetModuleHandle(0));

解决方案 »

  1.   

    where is your messgae pump?
      

  2.   

    BTW, how did you send your message?
      

  3.   

    pWnd->PostMessage(WM_USER, 0, 0);
    ::PostMessage(pWnd->m_hWnd, WM_USER, 0, 0);
    ::PostMessage(pWnd->GetSafeHwnd(), WM_USER, 0, 0);pWnd->SendMessage(WM_USER, 0, 0);
    ::SendMessage(pWnd->m_hWnd, WM_USER, 0, 0);
    ::SendMessage(pWnd->GetSafeHwnd(), WM_USER, 0, 0);以上几种SEND MESSAGE方法都接收不到,但是如果不是在COM中使用这个CWnd,就全可以收到。另外需要提的是,如果使用SendMessage,会在SendMessage语句处阻塞掉,因为在等待返回。有谁有这样的经验吗?谢谢!
      

  4.   

    How did you get pWnd? 
    try to use COM calles instead of sending messages
      

  5.   

    pWnd是CWnd的指针,在COM内有效的指针。什么是COM calles ?
      

  6.   

    结贴,请各位再次关注这个贴子!http://community.csdn.net/Expert/topic/4749/4749761.xml?temp=.7357447