Click to See Complete Forum and Search --> : CListCtrl ::URGENT


Rishi
May 17th, 1999, 10:56 AM
I am trying to drag and drop few elements across two different CListCtrls

How do I display different cursors like circle with a slash, shortcut etc?
I am not using OLE...
I am using SetDragCursorImage and CreateDragImage() but it only creates a black rectangle as the element image, which is not right..

Any hints?

olivier
May 18th, 1999, 10:13 AM
Here is the code that I'm using
===========================================================
/////////////////////////////////////////////////////////////////////////////
// OnBegindrag :
/////////////////////////////////////////////////////////////////////////////

void CGraphicListView::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult)
{
if (m_pDoc == NULL)
return;

if (m_pDoc->m_bEdit)
return;

NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;

m_pDoc->m_iColumnDrag = WhichColumn (pNMListView->ptAction.x);

if (m_pDoc->m_iColumnDrag != -1 && !(m_pDoc->m_iColumnDrag == 0 && m_pDoc->m_pSmallImageList != NULL))
{
SetCursor(m_pDoc->m_hCursorDrag); // set the icon
SetCapture();
m_bDragging = TRUE;
}
else
m_bDragging = FALSE;

*pResult = 0;
}

/////////////////////////////////////////////////////////////////////////////
// OnMouseMove :
/////////////////////////////////////////////////////////////////////////////

void CGraphicListView::OnMouseMove(UINT nFlags, CPoint point)
{
if (m_pDoc == NULL)
return;

if (m_bDragging)
{
UINT flags = TVHT_ONITEM;
int iHit = m_pListCtrl->HitTest(point, &flags);
int iColumn = WhichColumn (point.x);

if ((iColumn == 0 && m_pDoc->m_pSmallImageList != NULL)|| iColumn == m_pDoc->m_iColumnDrag)
iHit = -1;

if (iHit == -1)
SetCursor(m_pDoc->m_hCursorNoDrop);
else
SetCursor(m_pDoc->m_hCursorDrag);
}

CListView::OnMouseMove(nFlags, point);
}

/////////////////////////////////////////////////////////////////////////////
// OnLButtonUp :
/////////////////////////////////////////////////////////////////////////////

void CGraphicListView::OnLButtonUp(UINT nFlags, CPoint point)
{
if (m_bDragging)
{
// Reset boolean.
m_bDragging = FALSE;

// Release the mouse.
ReleaseCapture();


if (m_pListCtrl->HitTest(point, &nFlags) == -1)
return;

Drop(point);
}

CListView::OnLButtonUp(nFlags, point);
}

Rishi
May 18th, 1999, 10:19 AM
Oliver,

I am trying to drag and drop few elements across two different CListCtrls

Sorry the original post was not clear..

Do you know how I can display a element image (shadow) while the element is dragged?
And also I want to change the mouse cursor depending upon the drop target.

Thanks,
Rishi