Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Drag *to* Windows Explorer

There is a well documented possibility to control D&D operations from Windoes Explorer to a WindowsForms App.

I wonder if it is possible to intercept D&D operations from a drag source inside a WinForms application towards a folder inside Windows Explorer.

Just curious
Friday, September 26, 2003

Yes.  You just want to use a DataObject that supports the DataFormats.FileDrop format.  For this format, the corresponding data should be a string array, where each string is a full pathname.

Other than that, it's not much different than intra-application drag-and-drop.

Joe Cheng
Tuesday, September 30, 2003


doing it this way leads to Windows Explorer performing the actual d&d task, i.e. copying a file from a path to it's target path.

Another option could be to "suppress" Explorer activity (somehow?) and handle the action on the "drag" side, i.e. the own application. Does anyone know how to do this??

Tuesday, September 30, 2003

Depends on what you actually trying to achieve. Do you want to prevent some files being dragged from your application into the explorer or something else?

I might be missing something, but why don't you handle the dragging in the source in the first place? You can override onDragOver in the control that contains items you want to monitor, so then you can choose whether to allow a drag or not.

Alternatively, if are not in control of the drag source, you can monitor the clipboard via win32 api as described here:

This way you get the data before the drop is completed, so you can e.g. empty the clipboard to prevent the drop, or substitute the file drop data with yours - it's a bit drastic but depends really on what exactly you are trying to achieve.


Thursday, October 2, 2003

*  Recent Topics

*  Fog Creek Home