CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Guest

    CListCtrl Report

    OK, I want to just add the resource, fill it with data, and then click on it anywhere on the line then return nIndex (which row). I can fill it, but I cant get where it was clicked on or handle the whole line


  2. #2
    Join Date
    May 1999
    Posts
    25

    Re: CListCtrl Report

    int i, count = m_ctrlyourlist.GetItemCount();
    CString somevalue;

    for ( i=0; i < count; i++ )
    if ( m_ctrlyourlist.GetItemState( i, LVIS_SELECTED ) )
    {
    // get the data out of first column
    somevalue=m_ctrlyourlist.GetItemText( i,0);
    }


  3. #3
    Join Date
    May 1999
    Location
    Antwerp, Belgium
    Posts
    136

    Re: CListCtrl Report

    You can use the HitTest() method of CListCtrl.


  4. #4
    Join Date
    May 1999
    Posts
    116

    Re: CListCtrl Report

    You will need to decide when you want to do the action. It can be on a button click, or on a click in the list control (catch NM_CLICK), or when an item changes (LVN_ITEMCHANGED).

    Then in the code you can use GetNextItem to iterate through the list.int nSelItem = -1;
    while ( -1 != ( nSelItem = m_list.GetNextItem(nSelItem, LVNI_SELECTED) ) )
    {
    // Do stuff
    }




  5. #5
    Guest

    Re: CListCtrl Report

    1.subclass clistview
    2.Track lbuttondown message
    3.use CListCtrl HitTest function to get list item id


  6. #6
    Join Date
    Apr 1999
    Location
    Bangalore, India
    Posts
    25

    Re: CListCtrl Report

    In NM_CLICK use
    SubItemHitTest(LPLVHITTESTINFO HitInfo)

    This will return the iItem and iSubItem (in HitInfo structure). You also get the info whether the click was made on the item icon or item label or above or below or to the left or to the right of the client area of the list control.

    If click is made on the item,
    iItem = Item index and
    iSubItem = 0

    If the click is made on the subitem
    iItem = SubItem's parent item
    iSubItem = SubItem index



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