HitTest in ListView return LVHT_NOWHERE

G

Guest

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;
}
 
D

David Lowndes

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top