xyjiang
May 14th, 1999, 11:04 AM
Hi, I try to get the row number when clicking listview control by using HitTest(), but it doesn't.
I put the listview control on a dialog bar. Does it matter?
nIndex always returns -1 :(
void CMainFrame::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CListCtrl* pListCtrl = (CListCtrl*)m_wndDlgBar.GetDlgItem(IDC_LIST2);
DWORD dwPos = ::GetMessagePos() ;
CPoint point ((int) LOWORD (dwPos), (int) HIWORD (dwPos)) ;
pListCtrl->ScreenToClient (&point) ;
int nIndex ;
if ((nIndex = pListCtrl->HitTest (point)) != -1)
{
CString string = pListCtrl->GetItemText (nIndex, 0) ;
MessageBox(string) ;
}
*pResult = 0;
}
I put the listview control on a dialog bar. Does it matter?
nIndex always returns -1 :(
void CMainFrame::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CListCtrl* pListCtrl = (CListCtrl*)m_wndDlgBar.GetDlgItem(IDC_LIST2);
DWORD dwPos = ::GetMessagePos() ;
CPoint point ((int) LOWORD (dwPos), (int) HIWORD (dwPos)) ;
pListCtrl->ScreenToClient (&point) ;
int nIndex ;
if ((nIndex = pListCtrl->HitTest (point)) != -1)
{
CString string = pListCtrl->GetItemText (nIndex, 0) ;
MessageBox(string) ;
}
*pResult = 0;
}