Click to See Complete Forum and Search --> : CListCtrl Report


May 19th, 1999, 02:25 PM
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

czieler
May 19th, 1999, 03:18 PM
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);
}

Franky Braem
May 20th, 1999, 02:37 AM
You can use the HitTest() method of CListCtrl.

BrianOG
May 20th, 1999, 06:36 AM
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
}

May 20th, 1999, 03:19 PM
1.subclass clistview
2.Track lbuttondown message
3.use CListCtrl HitTest function to get list item id

Vicky
May 27th, 1999, 02:20 AM
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