How to get CListCtrl clicked item information !!

来源:互联网 发布:2018网络彩票能重启吗 编辑:程序博客网 时间:2024/05/21 17:33

you can use the follwing functions to find out the row selected or clicked.


POSITION posList=m_MyListControl.GetFirstSelectedItemPosition( );

int nGetNextSelectedItem=m_MyListControl.GetNextSelectedItem( posList) ;


In the above sample code the "m_MyListControl" is the control member variable of the listcontrol ( member variable define through class wizard).The return value of the function "GetNextSelectedItem( posList)" is the row number selected(starts from 0 row ).

 

 

CListCtrl* pListCtrl = (CListCtrl*) GetDlgItem(IDC_YOURLISTCONTROL);ASSERT(pListCtrl != NULL);POSITION pos = pList->GetFirstSelectedItemPosition();if (pos == NULL)   TRACE0("No items were selected!/n");else{   while (pos)   {      int nItem = pList->GetNextSelectedItem(pos);      TRACE1("Item %d was selected!/n", nItem);      // you could do your own processing on nItem here   }}
原创粉丝点击