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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Drag and drop to specific item in tree?

Drag and drop to specific item in tree?

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresquestion
3 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.
  • A Offline
    A Offline
    adonisv
    wrote on last edited by
    #1

    I'm trying to implement the ability to drag and drop a file onto a tree control, BUT it would be great if you could only drag onto certain objects. Is there a way to allow the user to drag a file onto the tree control and depending on what type of object the user drags the file over, drag and drop is allowed or disallowed? :~ It would be flimsy for them to have to select a tree item then drag and drop, much nicer if you simply drag the file to the object you want to add it to and if its allowed, it works! :-D

    M 1 Reply Last reply
    0
    • A adonisv

      I'm trying to implement the ability to drag and drop a file onto a tree control, BUT it would be great if you could only drag onto certain objects. Is there a way to allow the user to drag a file onto the tree control and depending on what type of object the user drags the file over, drag and drop is allowed or disallowed? :~ It would be flimsy for them to have to select a tree item then drag and drop, much nicer if you simply drag the file to the object you want to add it to and if its allowed, it works! :-D

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      When your IDropTarget::DragOver() method is called, you get a POINTL holding the cursor location. Convert that from screen coords to client coords (relative to the tree) then use TVM_HITTEST to find out which tree item that point is over. Once you get that, you can decide whether to allow the drop over that item. Return DROPEFFECT_NONE to not allow it, or DROPEFFECT_MOVE/COPY to allow it. --Mike-- Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber "Just because the box has 2 gigabytes of memory doesn't mean you get to use it all!"   -- Rico Mariani, CLR perf guy

      A 1 Reply Last reply
      0
      • M Michael Dunn

        When your IDropTarget::DragOver() method is called, you get a POINTL holding the cursor location. Convert that from screen coords to client coords (relative to the tree) then use TVM_HITTEST to find out which tree item that point is over. Once you get that, you can decide whether to allow the drop over that item. Return DROPEFFECT_NONE to not allow it, or DROPEFFECT_MOVE/COPY to allow it. --Mike-- Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber "Just because the box has 2 gigabytes of memory doesn't mean you get to use it all!"   -- Rico Mariani, CLR perf guy

        A Offline
        A Offline
        adonisv
        wrote on last edited by
        #3

        That's awesome thanks. :-D

        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