Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drag and drop files onto listview 2

Status
Not open for further replies.

Wings

Programmer
Feb 14, 2002
247
US
Hello,
I am looking to add drag and drop functionality to an application.
I would like the user to be able to select a file or folder and drag and drop it onto the listview in my app.
I have no idea where to begin with this.
How would I capture the path and name of the dropped item?
How would I know when a drop occurred?

Any help is appreciated.
 
Take a look at these articles. You may have to subscribe to get access to the ones you want. This e-mag is worth every penny.

James P. Cottingham
[sup]
There's no place like 127.0.0.1.
There's no place like 127.0.0.1.
[/sup]
 
I supposed that you just want the file path into the listbox, so here I leave some code to do something what u want:


1.-Into the .h file write this in the public section

BEGIN_MESSAGE MAP
MESSAGE_HANDLER (WM_DROPFILES, TMessage, WMDropFiles)
END_MESSAGE MAP (TComponent)

2.-In the private section write the event handler header:

void WMDropFiles (TMessage Message);

3.-The event handler should be something like this:

void Form1::WMDropFiles (TMessage Message)
{
int FileCount = DragQueryFile ((HANDLE) Message.WParams,
-1, FileName, 255);
//Where FileName is what you should add to the list
//The param -1 is to get the total number of files dragged
}


--- LastCyborg ---
 
I forgot to say that yous must declare a char identifier which will receive the params of the file name
in the public section write this:

char FileName[256];

--- LastCyborg ---
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top