解决方案 »

  1.   

    GetWindowRect,GetCursorPos,PtInRect获取判断是否在picture control里,是的话有需要可以再把这个点用ScreenToClient转换一下
      

  2.   

    这是我的程序:
    void Cw_dispctrlDlg::OnMouseMove(UINT nFlags, CPoint point)
    {
    // TODO: 在此添加消息处理程序代码和/或调用默认值
    CRect rect;
    //CPoint pt0;
    CString str_coordinate;
    GetDlgItem(IDC_STATIC1)->GetWindowRect(&rect);
    ScreenToClient(&rect);
    //ScreenToClient(&pt0);
    if(rect.PtInRect(point))
    {
    str_coordinate.Format("%d,%d",point.x,point.y);
    edit_status9.SetWindowText(str_coordinate);
    }
    else
    {
    edit_status9.SetWindowText(_T("1"));
    } CDialogEx::OnMouseMove(nFlags, point);
    }
    控件IDC_STATIC1旁边还有很多其他控件是连着放的,现在出现的情况就是只有鼠标移到对话框本身的空白区域的时候才显示1,而如果从IDC_STATIC1移到其他控件上时,坐标值就固定不变了,不知道是为什么呢?
      

  3.   

    在PreTranslateMessage中拦截WM_MOUSEMOVE消息,然后再处理,记得Point用GetCursorPos获取
      

  4.   

    void Cw_dispctrlDlg::OnMouseMove(UINT nFlags, CPoint point)
    {
    // TODO: 在此添加消息处理程序代码和/或调用默认值
    CRect rect;
    //CPoint pt0;
    CString str_coordinate;
    GetDlgItem(IDC_STATIC1)->GetWindowRect(&rect);
    ScreenToClient(&rect);
    //ScreenToClient(&pt0);
    if(rect.PtInRect(point))
    {
    str_coordinate.Format("%d,%d",point.x,point.y);
    edit_status9.SetWindowText(str_coordinate);
    }
    else
    {
    edit_status9.SetWindowText(_T("1"));
    } CDialogEx::OnMouseMove(nFlags, point);
    }
    BOOL Cw_dispctrlDlg::PreTranslateMessage(MSG* pMsg)
    {
    // TODO: 在此添加专用代码和/或调用基类
    CPoint pt;
    if(pMsg->wParam==WM_MOUSEMOVE)
    {
    ::GetCursorPos( &pt );
    }

    return CDialogEx::PreTranslateMessage(pMsg);
    }
    是这样吗?好像还是没有什么效果,我是新手,能不能指导再具体一些。万分感谢!