做了一个文件拷贝的东东,把文件名列在list列表里,第一列加了checkbox,怎么判断那些被选中?
之后怎么把选中的文件拷贝到指定目录?

解决方案 »

  1.   

    用个循环,逐个去GetCheck;
    CListCtrl::GetCheck
    This method determines if an item in a list view control is selected. This should be used only for list view controls that have the LVS_EX_CHECKBOXES style.BOOL GetCheck( 
    int nItem ) 
    const; 
    Parameters
    nItem 
    The zero-based index of a list control item. 
    Return Value
    Nonzero if the item is selected, otherwise, it is zero.Example
    // Pointer to the list view control.
    ClistCtrl* pmyListCtrl;int nCount = pmyListCtrl->GetItemCount();
    BOOL fCheck = FALSE;// Set the check of every other item to TRUE and
    // all others to FALSE.
    for (int i=0;i < nCount;i++)
    {
      pmyListCtrl->SetCheck(i, fCheck);
      ASSERT((pmyListCtrl->GetCheck(i) && fCheck) ||
         (!pmyListCtrl->GetCheck(i) && !fCheck));
      fCheck = !fCheck;
    }
      

  2.   

    // m_list.SetExtendedStyle(LVS_EX_CHECKBOXES); for(int i=0; i<m_list.GetItemCount(); i++) { if ( m_list.GetItemState(i, LVIS_SELECTED) == LVIS_SELECTED || m_list.GetCheck(i)) { AfxMessageBox("1"); } }