如果是这样的话,为什么不干脆直接发给自己呢?WM_NOTIFY_REFLECT是直接将消息发给自己么?

解决方案 »

  1.   

    OnNotify处理他,在OnNotify中
       if (ReflectLastMsg(hWndCtrl, pResult))
            return TRUE;        // eaten by child    AFX_NOTIFY notify;
        notify.pResult = pResult;
        notify.pNMHDR = pNMHDR;
        return OnCmdMsg((UINT)nID, MAKELONG(nCode, WM_NOTIFY), &notify, NULL);
    调用ReflectLastMsg将先发送反射消息控件处理,若控件处理了,那么后面就是return TRUE了,否则往下执行OnCmdMsg交给父窗口...
      

  2.   

    WM_NOTIFY Message--------------------------------------------------------------------------------Sent by a common control to its parent window when an event has occurred or the control requires some information. 
      

  3.   

    谢谢,那么WM_NOTIFY_REFLECT是直接将消息发给自己么??
    还请大侠继续指导!
      

  4.   


    WM_NOTIFY_REFLECT是什么?
    ReflectLastMsg最终调用的是BOOL CWnd::ReflectChildNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
    {
    // Note: reflected messages are send directly to CWnd::OnWndMsg
    //  and CWnd::OnCmdMsg for speed and because these messages are not
    //  routed by normal OnCmdMsg routing (they are only dispatched) switch (uMsg)
    {
    // normal messages (just wParam, lParam through OnWndMsg)
    case WM_HSCROLL:
    case WM_VSCROLL:
    case WM_PARENTNOTIFY:
    case WM_DRAWITEM:
    case WM_MEASUREITEM:
    case WM_DELETEITEM:
    case WM_VKEYTOITEM:
    case WM_CHARTOITEM:
    case WM_COMPAREITEM:
    // reflect the message through the message map as WM_REFLECT_BASE+uMsg
    return CWnd::OnWndMsg(WM_REFLECT_BASE+uMsg, wParam, lParam, pResult); // special case for WM_COMMAND
    case WM_COMMAND:
    {
    // reflect the message through the message map as OCM_COMMAND
    int nCode = HIWORD(wParam);
    if (CWnd::OnCmdMsg(0, MAKELONG(nCode, WM_REFLECT_BASE+WM_COMMAND), NULL, NULL))
    {
    if (pResult != NULL)
    *pResult = 1;
    return TRUE;
    }
    }
    break; // special case for WM_NOTIFY
    case WM_NOTIFY:
    {
    // reflect the message through the message map as OCM_NOTIFY
    NMHDR* pNMHDR = (NMHDR*)lParam;
    int nCode = pNMHDR->code;
    AFX_NOTIFY notify;
    notify.pResult = pResult;
    notify.pNMHDR = pNMHDR;
    return CWnd::OnCmdMsg(0, MAKELONG(nCode, WM_REFLECT_BASE+WM_NOTIFY), &notify, NULL);
    } // other special cases (WM_CTLCOLOR family)
    default:
    if (uMsg >= WM_CTLCOLORMSGBOX && uMsg <= WM_CTLCOLORSTATIC)
    {
    // fill in special struct for compatiblity with 16-bit WM_CTLCOLOR
    AFX_CTLCOLOR ctl;
    ctl.hDC = (HDC)wParam;
    ctl.nCtlType = uMsg - WM_CTLCOLORMSGBOX;
    //ASSERT(ctl.nCtlType >= CTLCOLOR_MSGBOX);
    ASSERT(ctl.nCtlType <= CTLCOLOR_STATIC); // reflect the message through the message map as OCM_CTLCOLOR
    BOOL bResult = CWnd::OnWndMsg(WM_REFLECT_BASE+WM_CTLCOLOR, 0, (LPARAM)&ctl, pResult);
    if ((HBRUSH)*pResult == NULL)
    bResult = FALSE;
    return bResult;
    }
    break;
    } return FALSE;   // let the parent handle it
    }你看,对于WM_NOTIFY消息,它是发送 WM_REFLECT_BASE+WM_NOTIFY 给子控件