现状: 我有一个dlg,上面放了一个button
想实现:我把鼠标放在button上,滚动鼠标滚轮,响应dlg的WM_MOUSEWHEEL消息处理函数?

解决方案 »

  1.   

    BOOL CXXXDlg::PreTranslateMessage(MSG* pMsg) 
    {
    // TODO: Add your specialized code here and/or call the base class
    if(pMsg->hwnd==GetDlgItem(IDC_SPEED_TEXT)->GetSafeHwnd() && pMsg->message==WM_MOUSEWHEEL)
    {
    //处理
    }
    return CDialog::PreTranslateMessage(pMsg);
    }
      

  2.   

    BOOL CXXXDlg::PreTranslateMessage(MSG* pMsg) 
    {
    // TODO: Add your specialized code here and/or call the base class
    if(pMsg->hwnd==GetDlgItem(ID_BUTTON1)->GetSafeHwnd() && pMsg->message==WM_MOUSEWHEEL)
    {
    //处理
    }
    return CDialog::PreTranslateMessage(pMsg);
    }
      

  3.   

    BOOL CXXXDlg::PreTranslateMessage(MSG* pMsg)
    {
    // TODO: Add your specialized code here and/or call the base class
    if(pMsg->hwnd==GetDlgItem(ID_BUTTON1)->GetSafeHwnd() && pMsg->message==WM_MOUSEWHEEL)
    {
      PostMessage(WM_MOUSEWHEEL, pMsg->Wparam, pMsg->Lparam);
    }
    return CDialog::PreTranslateMessage(pMsg);
    }