Wednesday, March 18, 2009

[VC++] Getting first item selected in CListCtrl

When you start to use CListCtrl, you may come in need of knowing the first selected index of a listcontrol. Here is how to find the same,
int nItemIdx = m_List.GetNextItem( -1, LVNI_SELECTED );
if( nItemIdx == -1 )
{
// No item selected
}
else
{
// nItemIdx holds the index of item selected
}

No comments: