|
-
May 17th, 1999, 09:41 PM
#1
Drag n' Drop? SOMEONE PLZ!!
ok, heres the deal. im tryin to learn mfc and here i am on tree controls. im trying to implement drag n' drop with them but the problem is that when i try to CreateDragImage(...), it always returns null. this is the code im usin(consequently its from the samples page on codeguru)
void CMyTreeCtrl::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
*pResult = 0;
m_hitemDrag = pNMTreeView->itemNew.hItem;
m_hitemDrop = NULL;
m_pDragImage = CreateDragImage(m_hitemDrag); //WHY WONT THIS RETURN A VALUE???
if(!m_pDragImage)
return;
m_bLDragging = true;
m_pDragImage->BeginDrag(0, CPoint(0,0) );
POINT pt = pNMTreeView->ptDrag;
ClientToScreen(&pt);
m_pDragImage->DragEnter(NULL, pt);
SetCapture();
}
i have a major programming project due in three weeks so any reply would be welcome.
thanks
L5
-
May 18th, 1999, 10:30 AM
#2
Re: Drag n' Drop? SOMEONE PLZ!!
m_hCursorNoDrop = AfxGetApp()->LoadCursor(IDC_NODROP);
m_hCursorDrag = AfxGetApp()->LoadCursor(IDC_DROP);
============================================================
void CMyTreeCtrl::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
SetCursor(m_hCursorDrag);
SetCapture();
*pResult = 0;
}
/////////////////////////////////////////////////////////////////////////////
// OnMouseMove :
/////////////////////////////////////////////////////////////////////////////
void CMyTreeCtrl::OnMouseMove(UINT nFlags, CPoint point)
{
if (m_bDragging)
{
if (iHit == -1)
SetCursor(m_hCursorNoDrop); // the No cursor
else
SetCursor(m_hCursorDrag); // the drag Cursor
}
CTreeCtrl::OnMouseMove(nFlags, point);
}
/////////////////////////////////////////////////////////////////////////////
// OnLButtonUp :
/////////////////////////////////////////////////////////////////////////////
void CMyTreeCtrl::OnLButtonUp(UINT nFlags, CPoint point)
{
if (m_bDragging)
{
// Reset boolean.
m_bDragging = FALSE;
// Release the mouse.
ReleaseCapture();
}
CTreeCtrl::OnLButtonUp(nFlags, point);
}
-
May 18th, 1999, 04:18 PM
#3
Re: Drag n' Drop? SOMEONE PLZ!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|