我使用ListCtrl做了一个可编辑的表格,其他都好了,就是调整不了编辑框的坐标位置,求高手指点:
核心代码如下:
    void CListDlg::OnDblclkList(NMHDR* pNMHDR, LRESULT* pResult) 
   {
// TODO: Add your control notification handler code here
         LPNMITEMACTIVATE temp = (LPNMITEMACTIVATE) pNMHDR;

nItem = temp->iItem;//获得行号

nSubItem = temp->iSubItem;//获得列号
//////////////////////////////////////////////////////////////////////////
//输出行列号
/* CString str;
str.Format("行号为%d列号为%d",nItem,nSubItem);
MessageBox(str);*/
/////////////////////////////////////////////////////////////////////////// if(nSubItem == -1 || nItem == -1)   
{
return ;
}
else
{
CString str;
str.Format("行号为%d列号为%d",nItem,nSubItem);
//MessageBox(str);
} CRect rect; m_List.GetSubItemRect(nItem,nSubItem,LVIR_LABEL,rect); m_edit.MoveWindow(&rect);
        m_edit.SetFocus();
::ShowWindow(::GetDlgItem(m_hWnd,IDC_EDIT1),SW_SHOW); ::Rectangle(::GetDC(temp->hdr.hwndFrom),
       rect.left,rect.top-1,rect.right,rect.bottom);

*pResult = 0;
}BOOL CListDlg::PreTranslateMessage(MSG* pMsg) 
{
// TODO: Add your specialized code here and/or call the base class
CWnd* pwndCtrl = GetFocus();
    // get the control ID which is 
    // presently having the focus
//MessageBox("123");
if(pwndCtrl   ==   NULL)

         return   CDialog::PreTranslateMessage(pMsg); 
     }

int ctrl_ID = pwndCtrl->GetDlgCtrlID();

if(pMsg-> message==WM_KEYDOWN && pMsg->wParam==VK_RETURN 
              &&ctrl_ID ==IDC_EDIT1) 
              { 
                          //AfxMessageBox("....."); 
Invalidate();
CString str;
GetDlgItemText(IDC_EDIT1,str);
m_List.SetItemText(nItem,nSubItem,str);
::ShowWindow(::GetDlgItem(m_hWnd,IDC_EDIT1),SW_HIDE);
::SetWindowText(::GetDlgItem(m_hWnd,IDC_EDIT1),"");
                          return   TRUE; 
              }    return CDialog::PreTranslateMessage(pMsg);}

解决方案 »

  1.   

    什么叫就是调整不了编辑框的坐标位置?你的编辑框怎么创建的?它的父窗口是CListCtrl吗?
      

  2.   

    CListCtrl不是可以用资源添加吗,位置用该是定的吧
      

  3.   

    是的  ,我的理解是  我得到的那个矩形,是以list为参考的,而movewindow是以屏幕或其他窗口为参考的,这样就不对了,我很晕:
             
    1、GetWindowRect                
    2、GetSubItemRect
    3、movewindow
      

  4.   


    SetWindowPos  看上去好难呀 哈哈 我刚学的 实在看不明白塌怎么用
      

  5.   

    MoveWindow用着个函数应该是可以的,你看看那你的坐标设制,最好换几次试试或许就可以了