在styles中去掉single selection的勾就可以多选但我怎么得到我多选的是哪几行呢?
比如我选了1,2,5行,我怎么得到1,2,5这几个值????
我定义了   CListCtrl       m_listctrl

解决方案 »

  1.   

    CListCtrl* pListCtrl = &m_listctrl;
    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
       }
    }
      

  2.   

    int selectNum;
    selectNum = m_listselect.GetSelCount();

    int* delpoint;
    delpoint = new int[selectNum];
    int nItems =m_listselect.GetSelItems(selectNum, delpoint); //delete[] delpoint1;这是我用的,在delpoint里就你选择的那些行,delpoint[0]==1 ,delpoint[1]=2, delpoint[2]=5,
    至于delpoint[3],那我就不知道啦,所以要小心点,用的时候,要注意selectNum,
      

  3.   

    list control控件中,怎样设置可以选择多行??? 
    除了在styles中去掉single selection的勾外,
    m_listctrl.SetExtendedStyle()还需要什么样式???
      

  4.   

    自己查MSDN,看看提供了多少种style
      

  5.   

    LB_GETSELITEMS Message--------------------------------------------------------------------------------An application sends an LB_GETSELITEMS message to fill a buffer with an array of integers that specify the item numbers of selected items in a multiple-selection list box. Syntax
    To send this message, call the SendMessage function as follows. 
    lResult = SendMessage(      // returns LRESULT in lResult     (HWND) hWndControl,      // handle to destination control     (UINT) LB_GETSELITEMS,      // message ID     (WPARAM) wParam,      // = (WPARAM) () wParam;    (LPARAM) lParam      // = (LPARAM) () lParam; );   
    ParameterswParam
    Specifies the maximum number of selected items whose item numbers are to be placed in the buffer. 
    Microsoft® Windows® 95/Windows 98/Windows Millennium Edition (Windows Me) : The wParam parameter is limited to 16-bit values. This means list boxes cannot contain more than 32,767 items. Although the number of items is restricted, the total size in bytes of the items in a list box is limited only by available memory.lParam
    Pointer to a buffer large enough for the number of integers specified by the wParam parameter. 
    Return ValueThe return value is the number of items placed in the buffer. If the list box is a single-selection list box, the return value is LB_ERR. Message InformationHeader Declared in Winuser.h, include Windows.h 
    Minimum operating systems Windows 95, Windows NT 3.1 See AlsoList Boxes, LB_GETSELCOUNT--------------------------------------------------------------------------------© 2004 Microsoft Corporation. All rights reserved.