Solved

How to Drag and Drop files ?

Posted on 2002-07-03
4
435 Views
Last Modified: 2013-11-20
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
Comment
Question by:anij
  • 2
4 Comments
 

Expert Comment

by:1cand01t
ID: 7128933
See following article in MSDN:

"Drag and Drop: Implementing a Drop Target"

also see the details of class "COleDropTarget".

goodluck.
0
 

Author Comment

by:anij
ID: 7130891
I don't have msdn
0
 

Expert Comment

by:1cand01t
ID: 7131040
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
 
LVL 37

Accepted Solution

by:
zzynx earned 100 total points
ID: 7131139
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Turn a spreadsheet into a vba executable. 2 95
Looking for a specific application/software 2 115
sum28 challenge 31 115
Way to decrease size of apk file 9 87
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question