• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 447
  • Last Modified:

How to Drag and Drop files ?

Hi Experts
I created a MFC app which deals with files and folders. I want to add drag and drop fecility
to this app. How can I achieve it. i.e when Files or folders are drag and drop to the CTreeCtrl of this app it will add such a node . plz help me.
0
anij
Asked:
anij
  • 2
1 Solution
 
1cand01tCommented:
See following article in MSDN:

"Drag and Drop: Implementing a Drop Target"

also see the details of class "COleDropTarget".

goodluck.
0
 
anijAuthor Commented:
I don't have msdn
0
 
1cand01tCommented:
To implement a drop target

"Add a member variable to each view in the application that you want to be a drop target. This member variable must be of type COleDropTarget or a class derived from it.


From your view class’s function that handles the WM_CREATE message (typically OnCreate), call the new member variable’s Register member function. Revoke will be called automatically for you when your view is destroyed.


Override the following functions. If you want the same behavior throughout your application, override these functions in your view class. If you want to modify behavior in isolated cases or want to enable dropping on non-CView windows, override these functions in your COleDropTarget-derived class.

OnDragEnter: Drop operations to occur in the window. Called when the cursor first enters the window.

OnDragLeave: Special behavior when the drag operation leaves the specified window.

OnDragOver: Drop operations to occur in the window. Called when the cursor is being dragged across the window.

OnDrop: Handling of data being dropped into the specified window."


In treeview u can use HitTest() function to check on which treeitem the file was dropped.
0
 
zzynxSoftware engineerCommented:
First:
You don't need to have MSDN to be able to consult MSDN articles. There's the internet, you know? http://msdn.microsoft.com

Second:
This article may interest you: http://www.codeproject.com/useritems/rdragdropfiles.asp

Success.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now