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

    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




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

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



  3. #3
    Join Date
    May 1999
    Posts
    37

    Re: Drag n' Drop? SOMEONE PLZ!!

    thanks, ill try it
    L5


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