CRect rect; pButton=(CButton*)GetDlgItem(IDC_BUTTON_DELETE); 
 pButton->GetWindowRect(&rect );

解决方案 »

  1.   

    CRect m_rectClient;
    m_btnXXX.GetClientRect(m_rectClient);//then you retrieve the client coordinate
    if you want to get the screen coordinate,you could call function;
    m_btnXXX.GetWindowRect(m_rectClient);//the coordinate you get will base on 
    screen coordinate which use the screen Left-Top point as its (0,0) point!
      

  2.   

    CRect m_rectClient;
    m_btnXXX.GetClientRect(m_rectClient);//then you retrieve the client coordinate
    if you want to get the screen coordinate,you could call function;
    m_btnXXX.GetWindowRect(m_rectClient);//the coordinate you get will base on 
    screen coordinate which use the screen Left-Top point as its (0,0) point!
      

  3.   

    也可以这样
    CRect rect;
    GetDlgItem(IDC_BUTTON1)->GetWindowRect(&rect);
    ::GetWindowRect(::GetDlgItem(GetSafeHwnd(),IDC_BUTTON1),&rect);
      

  4.   

    CButton 是 CWnd 的子类。
    凡是CWnd的,都可以GetWindowRect();
    得到的Rect是相对Screen的。
    CWnd还提供ScreenToClient()和ClientToScreen()用来转换坐标。。