Click to See Complete Forum and Search --> : How to "HitTest" to determine ...


craig knutson
May 5th, 1999, 09:52 AM
... if a "click" has happened ON the item icon in a listctrl?

here is my OnLButtonDown() routine:

*** begin code snipit ***
void CobolJclgenListctrl_params::OnLButtonDown(UINT nFlags, CPoint point){
UINT uiFlags;
int iIndex = HitTest(point,&uiFlags);
TRACE(_T("Hit index = %i\n"),iIndex);
if (uiFlags&LVHT_ABOVE){
TRACE("%s\n",_T("LVHT_ABOVE"));
}
if (uiFlags&LVHT_BELOW){
TRACE("%s\n",_T("LVHT_BELOW"));
}
if (uiFlags&LVHT_NOWHERE){
TRACE("%s\n",_T("LVHT_NOWHERE"));
}
if (uiFlags&LVHT_ONITEMICON){
TRACE("%s\n",_T("LVHT_ONITEMICON"));
}
if (uiFlags&LVHT_ONITEMLABEL){
TRACE("%s\n",_T("LVHT_ONITEMLABEL"));
}
if (uiFlags&LVHT_ONITEMSTATEICON){
TRACE("%s\n",_T("LVHT_ONITEMSTATEICON"));
}
if (uiFlags&LVHT_TOLEFT){
TRACE("%s\n",_T("LVHT_TOLEFT"));
}
if (uiFlags&LVHT_TORIGHT){
TRACE("%s\n",_T("LVHT_TORIGHT"));
}
// pass the call on to my parent
CobolJclgenListctrlFS::OnLButtonDown(nFlags,point);
}
*** end code snipit ***

when i click "anywhere" on the 1 item i have inserted into the listctrl, i get the following results.

Hit index = 0
LVHT_ABOVE
LVHT_ONITEMICON
LVHT_ONITEMLABEL
LVHT_ONITEMSTATEICON


i was hoping that if i clicked on the icon, (i.e. this is in "report" view, and i have a small icon that is being used), i would get only LVHT_ONITEMICON back, because i want to do something different if the icon is clicked on, and other things if the lable, or one of the other columns is clicked on.

thanks for any advice you can provide

craigk
cknutson@flash.net

craig knutson
May 5th, 1999, 02:03 PM
the problem turned out to be with one of my "parent" classes that i had derived from CListCtrl. it was getting in the way somehow.

thanks anyway.

craigk
cknutson@flash.net