Hi,
I get LVHITTESTINFO::Flag=LVHT_NOWHERE when I do a Hit Test in my ListView.
The list containts items and subitems created with designer. Clicking
anywhere in the list makes not HitTest return valid Index (return -1). Why?
Hugo
// Called by ListView::MouseUp with x=e->get_X() and y=e->get_Y()
bool Main::GetModeSettingFieldParam(int x, int y, int* pItemIndex, int*
pSubItemIndex, System::Drawing::Rectangle* pBounds)
{
LVHITTESTINFO HitTestInfo;
HitTestInfo.pt.x = x;
HitTestInfo.pt.x = y;
ModeSetting->Focus();
/**pItemIndex =*/ SendMessage(GetFocus(), LVM_SUBITEMHITTEST, 0, (LPARAM)
&HitTestInfo);
//ListView_SubItemHitTest(GetFocus(), &HitTestInfo);
*pItemIndex = HitTestInfo.iItem;
*pSubItemIndex = HitTestInfo.iSubItem;
System::Diagnostics::Trace::Write((*pItemIndex).ToString(), S"Index ");
System::Diagnostics::Trace::Write((*pSubItemIndex).ToString(), S" ; SubIndex
");
System::Diagnostics::Trace::WriteLine(HitTestInfo.flags.ToString(), S" ;
Flag ");
return *pItemIndex != -1;
}
David Lowndes - 13 Oct 2005 20:48 GMT
>I get LVHITTESTINFO::Flag=LVHT_NOWHERE when I do a Hit Test in my ListView.
Hugo,
Try calling ScreenToClient on the co-ords to convert to screen co-ords
before you call HitTest.
Dave

Signature
MVP VC++ FAQ: http://www.mvps.org/vcfaq