获得一个编辑框,的client坐标是不是编辑框的左上角为原点。?

解决方案 »

  1.   

    是的。
    GetWindowRect得到的是屏幕坐标
      

  2.   


    为什么不对呢!
    GetClientRect的左上角为0,0
      

  3.   

    CWnd *p=GetDlgItem(IDC_EDIT1);
    CRect rect;
    p->GetWindowRect(rect); 
    CString str;
    str.Format("%d,%d",rect.top ,rect.left); 
    AfxMessageBox(str);
      

  4.   

    GetWindowRect(rect); 
    得到是屏幕坐标吧
      

  5.   

    CWnd *pWnd = GetDlgItem(IDC_UR_BUTTON);
    CRect rect;
    如果返回相对屏幕的坐标,那么:
    pWnd->GetWindowRect(&rect);如果返回相对对话框的左边那么:
    pWnd->GetWindowRect(&rect);
    ScreenToClient(&rect);如果返回本身的尺寸大小
    pWnd->GetClientRect(&rect); //此时rect.left, rect.top 都是0
    我想这些对楼主应该有帮助
      

  6.   

    如果返回相对对话框的左边那么:
    pWnd->GetWindowRect(&rect);
    ScreenToClient(&rect);
    问小黄鱼,此时的坐标原点在对话框的left和top吗?