Windows: Drag and Drop Folders (again)


This has been mentioned over the years in other channels, but the options given there are not working for me.

I want to be able to drop a folder on my application or application window and then process the resulting folder items.

On a mac this works fine. On Windows I am not getting any DropObject or OpenDocument event.

I have a file type “Special/Folder”,“SpecialFolder”,“fold”,“MACS”

On the open event for both the app window and a field in the window I have .AcceptFileDrop(FileTypes1.SpecialFolder)

In the Application I just put up a msgbox in the “OpenDocument” event.

…and on Macs this works fine. Using XOJO r3 and RS 2012

All thoughts appreciated,


That makes sense. ‘fold’ and ‘MACS’ are Mac-exclusive properties. (The others are just macros to the same Mac things.)

Windows deals with FileTypes differently. Mac’s have some native types, but (to Xojo anyway) Windows doesn’t have any. This is one of these things that Xojo doesn’t make xplat for you and shows how Mac-centric Xojo is. You have to accept everything (AcceptFileDrop("???")) and then filter it out on MouseEnter or DropObject.

Thanks for the quick reply. I removed the other filetypes and just have AcceptFileDrop("???") in the window and field .open with no change in the results.

I also tried adding a filetype with “???” and then referencing that, still no change.

I am getting the slash when I drag over either.

Is it worth mentioning that I am remote debugging?

All I can comment on is; I do this, very simply, nothing else:

-Open RS2011r3
-New Project
-In the Window1.Open, I put Me.AcceptFileDrop("???")
-In the Window1.DropObject, I check for FolderItemAvailable, and then I print FolderItem.AbsolutePath in a Label I put on the Window.
-Run, I drop any file on the Window, it displays the path in the Label

I know that isn’t Xojo, but this should work. If it was broken in a production version of Xojo, lots of hell would be breaking loose. This is completely necessary.

I don’t know about Remote Debugging, I don’t trust it, but then again I never tried it. I totally believe in debugging on the exact thing you are testing on, but maybe I’m a ostrich. I don’t see how you can be authoritative to a customer unless you are apples-apples with what he’s trying.

Todd, I am assuming that you are not interested in dropping files themselves, only folders. If that is true, then try adding the following code to the DragEnter event for the window/control/whatever you want to drop the folder on.

if obj.FolderItem.Directory = False then Return True

This should prevent anything but a folder from being dropped. After the drop, what you do with the folder or its contents is up to you.

Thanks for all the help but it looks like a Remote Debugger issue… if I do the same thing from XOJO on Windows it works, but the same code sent over the debugger does not. Will file a bug report.