CListViewCtrl HitTest problem
-
As topic says, I'm having some HItTest issue. Background: I'm making a windows mobile ce 6.5 application. There is some resource based dialog with ListView on it. I'm subclassing the ListView with "CustomLVCtrl" and HeaderCtrl with "CustomHCtrl". Both custom controls have increased height based on some constant value. Now about my problem: From WM_GESTURE GID_HOLD handler i'm getting some screen coordinates and then testing if any ListView item is being hold. The problem is that i'm never getting a valid item index. It looks like item with index 0 is under the header, because testing first item results in 1, second returns 2, ..., then last returns -1. These results are not accurate for the whole item height either. Simplified code:
void Controller::onHold(int x, int y)
{
CPoint point(x, y);
view_->list_.ScreenToClient(&point);
LONG dlgBaseUnits = GetDialogBaseUnits();
int baseunitX = LOWORD(dlgBaseUnits), baseunitY = HIWORD(dlgBaseUnits);
point.x = ATL::MulDiv(point.x, 4, baseunitX);
point.y = ATL::MulDiv(point.y, 8, baseunitY);
LVHITTESTINFO lvhti;
lvhti.flags = 0;
lvhti.pt = point;
int nItem = view_->list_.HitTest(&lvhti);
if (lvhti.flags & LVHT_ONITEM)
{
ShowModal(nItem);
}
}I've also tried with
RECT rect={0,0,4,8}; MapDialogRect(hwnd, &rect); int baseunitX = rect.right; int baseunitY = rect.bottom; point.x = ATL::MulDiv(point.x, 4, baseunitX); point.y = ATL::MulDiv(point.y, 8, baseunitY);
but with same results. Can anyone point out what I'm doing wrong?