MFC里mousemove函数如下
void CGobangView::OnMouseMove(UINT nFlags, CPoint point) 
{
// TODO: Add your message handler code here and/or call default


int x = point.x;
int y = point.y;
CString st;
st.Format(("%d,%d"), point.x, point.y);
CDC *pDC = GetDC();
pDC->TextOut(20, 20, st);
ReleaseDC(pDC);
SetCursor(LoadCursor(NULL, IDC_CROSS)); CView::OnMouseMove(nFlags, point);
}但是显示的时候左上角y的坐标会很大,明显不对啊,哪里出问题了。。求指导

解决方案 »

  1.   

    void CCDlgDlg::OnMouseMove(UINT nFlags, CPoint point)
    {
    CString str;
    str.Format(_T("x=%d,y=%d"),point.x,point.y);
    SetWindowText(str); CDialog::OnMouseMove(nFlags, point);
    }
      

  2.   

    注意视图坐标和屏幕坐标的转换ClientToScreen,ScreenToClient之类的
      

  3.   

    st.Format(("%8d, %8d"), point.x, point.y);
    覆盖显示的可能性很大,充分拉开显示距离或显示之前刷背景
      

  4.   

    afx_msg void OnMouseMove(
       UINT nFlags,
       CPoint point 
    );
     
    point
    Specifies the x- and y-coordinate of the cursor. These coordinates are always relative to the upper-left corner of the window.