Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. CListViewCtrl HitTest problem

CListViewCtrl HitTest problem

Scheduled Pinned Locked Moved ATL / WTL / STL
helpc++databasetestingbeta-testing
1 Posts 1 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    ush_
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups