|
-
August 30th, 1999, 03:36 AM
#1
CListCtrl
Hi,
I am trying to do the following: If the user clicks anywhere on a CListCtrl (doesn't have to be the first column), the matching item should be selected. For this action, I am using code I found on codeguru's control section.
Why isn't it working?
void CPreislisteDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnLButtonDown(nFlags, point);
int index;
point.x = 2;
if((index = m_cPreisListe.HitTest(point, NULL)) != -1)
{
MessageBox("OK");
m_cPreisListe.SetItemState(index, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
}
}
Thanks!
Fox20
-
August 30th, 1999, 04:43 AM
#2
Re: CListCtrl
Hi,
OnLButtonDown gives you the coordinates in coordinates relative to the dialog, but HitTest expects them to be relative to the CListCtrl. So you need to convert them with MapWindowPoints.
But a better way will be to write a handler for the NM_CLICK message. It will give you not only the point where clicked, but also which item and subitem.
Martin
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|