Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Enhanced drag and drop

Enhanced drag and drop

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++comdata-structuresdebugging
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wfalby
    wrote on last edited by
    #1

    I have an MDI application implemented using third-party controls. I have implemented the basic OLE drag and drop. I am stuck trying to get a tree node to expand when I hover over it. My code implements the OnDragOver, OnDrop, OnDragLeave, OnDragEnter, OnBeginDrag. The sample code uses the old style drag and drop. When I add OnMouseMove and OnTimer methods, they never get control. I have debug tracing in the various methods. I have looked at Jeff Prosise's book but have found nothing that seems similar to my situation. I have tried moving the code from OnMouseMove to OnDragOver. Then the OnTimer method does not get invoked. I have tried calling SetFocus, but that does not help either. I am a MFC novice. Can anyone point me in the right direction?

    T 1 Reply Last reply
    0
    • W wfalby

      I have an MDI application implemented using third-party controls. I have implemented the basic OLE drag and drop. I am stuck trying to get a tree node to expand when I hover over it. My code implements the OnDragOver, OnDrop, OnDragLeave, OnDragEnter, OnBeginDrag. The sample code uses the old style drag and drop. When I add OnMouseMove and OnTimer methods, they never get control. I have debug tracing in the various methods. I have looked at Jeff Prosise's book but have found nothing that seems similar to my situation. I have tried moving the code from OnMouseMove to OnDragOver. Then the OnTimer method does not get invoked. I have tried calling SetFocus, but that does not help either. I am a MFC novice. Can anyone point me in the right direction?

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      I was able to implement this feature for OLE drag'n'drop in CTreeCtrl. I had to derive the class from COleDropTarget and override OnDragScroll method. This way I was able to handle the scrolling and expanding during the DnD. I'm including the code here, surely it will be formatted incorrectly, but may be helpful. DROPEFFECT CNavigationTree::DropTarget::OnDragScroll(CWnd *pWnd, DWORD dwKeyState, CPoint point) { DROPEFFECT dropEffect = DropEffectFromKeyState(dwKeyState); DWORD currentTicks = ::GetTickCount(); CTreeCtrl &tree = *static_cast(pWnd); UINT flags; HTREEITEM hti = tree.HitTest(point, &flags); if (hti != m_htiLastItem) { m_htiLastItem = hti; m_lastItemTicks = currentTicks; } if (currentTicks - m_lastTicks < DD_DEFSCROLLDELAY) { return dropEffect; } m_lastTicks = currentTicks; if (NULL != hti) { if (point.y < DD_DEFSCROLLINSET) { tree.SendMessage(WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), NULL); return dropEffect | DROPEFFECT_SCROLL; } CRect rcClient; tree.GetClientRect(rcClient); if (point.y > rcClient.bottom - DD_DEFSCROLLINSET) { tree.SendMessage(WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), NULL); return dropEffect | DROPEFFECT_SCROLL; } if (currentTicks - m_lastItemTicks > 500 && (flags & (TVHT_ONITEM | TVHT_ONITEMBUTTON)) != 0 && tree.ItemHasChildren(hti) && tree.GetItemState(hti, TVIS_EXPANDED) != TVIS_EXPANDED) { tree.Expand(hti, TVE_EXPAND); } } return dropEffect; } Tomasz Sowinski http://www.shooltz.com.pl

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups