在ListCtrl控件中如何返回鼠标选中项的索引值?请指明较详细的方法

解决方案 »

  1.   

    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
       }
    }