المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : CreateImageEx problem with CListCtrl drag and drop



C++ Programming
06-15-2009, 07:41 PM
Dear All,

I have problem with the CListCtrl drag and drop. I used the CreateImageEx to display the image while dragging the contents of the CListCtrl but unfortunately the image is displaying at the left top corner of the screen and not relevant to my GUI where the CListCtrl is placed.

The following is the code snippet. Please advice why the image is displayed like that.


//call to the dragging method
void TestDlg::OnLvnBeginrdragList3(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast(pNMHDR);
OnBegindrag(&pList, pNMHDR);
*pResult = 0;
}

//Dragging method
void TestDlg::OnBegindrag(CListCtrl* pList, NMHDR* pNMHDR)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
if (pList->GetSelectedCount() GetSelectedCount();
POINT pt;
m_pDragImage = CreateDragImageEx(pList, &pt);
if (m_imageList == NULL)
return;
m_pDragWnd = pList;
CPoint ptStart = pNMListView->ptAction;
ptStart -= pt;
m_pDragImage->BeginDrag(0, ptStart);
m_pDragImage->DragEnter(GetDesktopWindow(), pNMListView->ptAction);
SetCapture();
}