15,978
社区成员
发帖
与我相关
我的任务
分享
// this function drops an item from a CListCtrl to a CListCtrl
void CListCtrlView::DropItemOnList (CListCtrl* pDropList)
{
// unhilite the drop target
pDropList->SetItemState (m_nDropIndex, 0, LVIS_DROPHILITED);
char szLabel[256];
LV_ITEM lvi;
ZeroMemory (&lvi, sizeof (LV_ITEM));
lvi.iItem = m_nDragIndex;
lvi.mask = LVIF_IMAGE | LVIF_TEXT;
lvi.pszText = szLabel;
lvi.cchTextMax = 255;
// get item that was dragged
VERIFY (m_List.GetItem (&lvi));
// insert item into CListCtrl
lvi.iItem = (m_nDropIndex == -1) ? pDropList->GetItemCount () : m_nDropIndex;
VERIFY (-1 != pDropList->InsertItem (&lvi));
// select the new item we just inserted
VERIFY (pDropList->SetItemState (lvi.iItem, LVIS_SELECTED, LVIS_SELECTED));
// delete the original item (move operation)
VERIFY (m_List.DeleteItem (m_nDragIndex));
}