添加OnClickListu()
void CUserDialog::OnClickListu(NMHDR* pNMHDR, LRESULT* pResult)
{
Invalidate();
HWND hWnd1 = ::GetDlgItem (m_hWnd,IDC_LISTU);//IDC_LISTU是CClistCtrl的ID
LPNMITEMACTIVATE temp = (LPNMITEMACTIVATE) pNMHDR;
RECT rect;
//get the row number
nItem = temp->iItem;
//get the column number
nSubItem = temp->iSubItem;
//Retrieve the text of the selected subItem
//from the list
CString str = GetItemText(hWnd1,nItem ,nSubItem);
RECT rect1,rect2;
// this macro is used to retrieve the Rectanle
// of the selected SubItem
ListView_GetSubItemRect(hWnd1,temp->iItem,
temp->iSubItem,LVIR_BOUNDS,&rect);
//Get the Rectange of the listControl
::GetWindowRect(temp->hdr.hwndFrom,&rect1);
//Get the Rectange of the Dialog
::GetWindowRect(m_hWnd,&rect2);
int x=rect1.left-rect2.left;
int y=rect1.top-rect2.top;
if(nItem != -1)
::SetWindowPos(::GetDlgItem(m_hWnd,IDC_EDITL),//IDC_EDITL是一个编辑框控件ID
HWND_TOP,rect.left+x+3,rect.top+14,
rect.right-rect.left - 3,
rect.bottom-rect.top -1,NULL);
::ShowWindow(::GetDlgItem(m_hWnd,IDC_EDITL),SW_SHOW);
::SetFocus(::GetDlgItem(m_hWnd,IDC_EDITL));
//Draw a Rectangle around the SubItem
::Rectangle(::GetDC(temp->hdr.hwndFrom),
rect.left,rect.top-4,rect.right,rect.bottom);
//Set the listItem text in the EditBox
::SetWindowText(::GetDlgItem(m_hWnd,IDC_EDITL),str);
*pResult = 0;
}