CreateImageEx problem with CListCtrl drag and drop
-
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<LPNMLISTVIEW>(pNMHDR);
OnBegindrag(&pList, pNMHDR);
*pResult = 0;
}//Dragging method
void TestDlg::OnBegindrag(CListCtrl* pList, NMHDR* pNMHDR)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
if (pList->GetSelectedCount() <= 0)
return; // No row selected
int iItem = pList->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();
} -
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<LPNMLISTVIEW>(pNMHDR);
OnBegindrag(&pList, pNMHDR);
*pResult = 0;
}//Dragging method
void TestDlg::OnBegindrag(CListCtrl* pList, NMHDR* pNMHDR)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
if (pList->GetSelectedCount() <= 0)
return; // No row selected
int iItem = pList->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();
}Please anybody help me!!!