CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    11

    CListCtrl ::URGENT

    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?





  2. #2
    Join Date
    May 1999
    Location
    Paris, France
    Posts
    216

    Re: CListCtrl ::URGENT

    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);
    }



  3. #3
    Join Date
    Apr 1999
    Posts
    11

    Re: CListCtrl ::URGENT

    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



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured