here is the function:
void CPageNotes::OnNMClickListNotes(NMHDR *pNMHDR, LRESULT *pResult)
{
// TODO: Add your control notification handler code here
// get mouse coords
DWORD mousePos = GetMessagePos();
POINT p;
CPoint cp;
p.x = GET_X_LPARAM(mousePos);
p.y = GET_Y_LPARAM(mousePos);
// change mouse coords to CListCtrl mouse coords
ScreenToClient(&p);
cp.x = p.x;
cp.y = p.y;
UINT flag;
// check if click hit a item
if( m_Notes.HitTest(cp,&flag) == -1 )
{
MessageBox("hi","crap",MB_OK);
}
*pResult = 0;
}
any help would be appreciated,
thanks
Dave
Followed is a piece of sample code:
CListCtrl& ctrlDataList = GetListCtrl();
C**::OnLClick(NMHDR* pNMHDR, LRESULT* pResult)
{
CListCtrl& ctrlDataList = GetListCtrl();
DWORD dwPos = ::GetMessagePos();
CPoint pointCur((int)LOWORD(dwPos), (int)HIWORD(dwPos));
ctrlDataList.ScreenToClient(&pointCur);
LVHITTESTINFO lvhti;
lvhti.pt = pointCur;
ctrlDataList.SubItemHitTest(&lvhti);
if(lvhti.flags & LVHT_ONITEMLABEL)
{
// lvhti.sSubItem now equals to subitem index
}
}
BTW, HitTest() only works for the first Column.
"David Reynolds" <david_m_...@hotmail.com> wrote in message
news:3c892dd8$1...@corp-news.newsgroups.com...
Is CPageNotes the class that is a subclass of the CListControl?
If not then the CPoint you are building is based on the top left of the
container of the List control and therefor Hit Test is reporting correctly.
There are two things you can do here. The best way is to subclass the
CListControl and handle the click event through OnLButtonDown(UINT nFlags,
CPoint point) notice here the point is given to you and you do not have to
generate it. This is the "more correct" :-) way since in OOP each object
should handle it's own events anyway.
The other way is to offset the calculated point by the difference between
the top left of the container and the top left of the List control.
Hope this helps.
Steven Szelei
"David Reynolds" <david_m_...@hotmail.com> wrote in message
news:3c892dd8$1...@corp-news.newsgroups.com...
CPageNotes is a subclass of CPropertyPage, so I guess I'd have to calculate
the offset. Buy how do I do that?
thanks,
Dave
"sszelei" <ssz...@softprossoftware.com> wrote in message
news:uFfdDwuxBHA.2520@tkmsftngp05...
ON_NOTIFY_REFLECT(NM_CLICK, OnClick)
void CBaseListCtrl::OnClick(NMHDR* pNMHDR, LRESULT* )
{
NMITEMACTIVATE * pItem = (NMITEMACTIVATE*)pNMHDR;
pItem->iSubItem; // here is your iSubItem
pItem->iItem; // here is your iItem
}
I have only used this in report mode, but i suppose it should work in other
modes as well.
Marco
"David Reynolds" <david_m_...@hotmail.com> wrote in message
news:3c892dd8$1...@corp-news.newsgroups.com...