Dialog中有个OnLButtonDown的处理函数
希望能截获所有的对话框上的左键点击,
但是发现如果点一个按钮的话,不会执行Dialog::OnLButtonDown
应该怎么处理一下呢?
//bow

解决方案 »

  1.   

    在button的派生类中处理WM_LBUTTONDOWN
      

  2.   

    在PreTranslateMessage里处理,然后返回TRUE
      

  3.   

    或向对话框发送SendMessage(hDlg,WM_LBUTTONDOWN,....);
      

  4.   

    PreTranslateMessage是王道
    判断pMsg->message == WM_LBUTTONDOWN或者向父窗口发送WM_LBUTTONDOWN消息
      

  5.   

    这样怎么不行呢class CNewButton:public CButton
    {
    public:
    CNewButton(){ };
    ~CNewButton(){};
    virtual BOOL PreTranslateMessage(MSG* pMsg);
    };
    BOOL CNewButton::PreTranslateMessage(MSG* pMsg)
    {
    if(pMsg->message==WM_LBUTTONDOWN||pMsg->message==WM_LBUTTONUP)
    return TRUE;
    else
    return FALSE;
    }在CTestDlg中,有: CNewButton m_Action;
    void CTestDlg::OnLButtonDown(UINT nFlags, CPoint point) 
    {
    TRACE("Dlg:Down\n");
    CDialog::OnLButtonDown(nFlags, point);
    }
    发现还是在按钮外面按的时候有反映,里面没有
      

  6.   

    BOOL CNewButton::PreTranslateMessage(MSG* pMsg)
    {
    if(pMsg->message==WM_LBUTTONDOWN||pMsg->message==WM_LBUTTONUP)
    {
    ::SendMessage(m_pDlg->GetSafeHwnd(),pMsg->message,pMsg->wParam,pMsg->lParam);
    return FALSE;
    }
    else
    return FALSE;
    }
    改成这样可以了。传进来一个Dialog指针。总觉得比较土