CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Posts
    14

    How to "HitTest" to determine ...

    ... 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
    [email protected]



  2. #2
    Join Date
    May 1999
    Posts
    14

    Re: How to "HitTest" to determine ...

    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
    [email protected]


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured