Solved

How to Drag and Drop files ?

Posted on 2002-07-03
4
431 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now