跟我遇到的问题差不多。我查了,大概是这种意思:如果是postmessage的消息,在被处理之前有机会被PreTranslateMessage截取。所以你的PreTranslateMessage中处理时候消息还没加入消息队列。而加入消息队列后,子控件(当前窗口)可以处理,你的消息就这里被干掉,所以是不会再往父窗口传的。消息的传递是
由近到远,由孙子到祖宗。中间如果被截取了,就不是这样了。
而且你的逻辑似乎有点问题,CEdit是系统的控件,都写好了的,怎么会从自己的类里派生出来呢?

解决方案 »

  1.   

    我是要用CEdit和CListBox实现自动匹配功能的控件。
    找到了PreTranslateMessage的源码,在当前窗口的PreTranslateMessage返回FALSE时会调用父窗口的PreTranslateMessage:
    //thrdcore.cpp
    BOOL CWinThread::PreTranslateMessage(MSG* pMsg)
    {
     ASSERT_VALID(this); // 如果是线程消息,那么将会调用线程消息的处理函数
     if (pMsg->hwnd == NULL && DispatchThreadMessageEx(pMsg))
      return TRUE; // walk from target to main window
     CWnd* pMainWnd = AfxGetMainWnd();
     if (CWnd::WalkPreTranslateTree(pMainWnd->GetSafeHwnd(), pMsg))
      return TRUE; // in case of modeless dialogs, last chance route through main
     // window's accelerator table
     if (pMainWnd != NULL)
     {
      CWnd* pWnd = CWnd::FromHandle(pMsg->hwnd);
      if (pWnd->GetTopLevelParent() != pMainWnd)
       return pMainWnd->PreTranslateMessage(pMsg);
     } return FALSE; // no special processing
    }