Drag and Drop in Windows with Explorer

I need to make a Windows program with RXRuby that batch processes audio
files, after the user drags them from Explorer to the program’s window.

This works easily in Linux, I just accept “text/uri-list”. I was trying
to find the Windows equivalent, so I wrote some code to list the offered
types, which also works great in Linux. But in Windows (I tried XP and
98SE), when dragging files from Explorer, I don’t even get a
SEL_DND_MOTION. My code is attached.

Is it possible to get dropped files in Windows, and if so, how?

Thanks,

filedropper.rb (756 Bytes)

···


Tom Felker tcfelker@mtco.com

Hi Tom,

Sorry, I don’t have an answer to your question. I had a quick play with this some time back and didn’t get anywhere.

If you get the code to work under Windows, can you post the final version to the mailing list?

Cheers,

Harry O.

Sure, I’ll post any working code I get, but I’m a bit discouraged by my
further research:

http://www.escribe.com/software/foxusers/m4610.html

According to this, on Windows, Fox does DND in it’s own way, not
Window’s way, because OLE is too weird to be cross-platform.
Unfortunately, Windows developers, and certainly Microsoft, won’t jump
to change their DND to work with Fox.

http://www.escribe.com/software/foxusers/m4066.html
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/legacyinformation/shelllib.asp

However, while most of Windows uses OLE or COM or some other hip TLA,
there’s also a special API for file dropping, and this person hacked up
a way to do this in C++. This can be done in plain Ruby and FXRuby,
given the ability:

  • To call Windows functions (Yes)
  • To access a given FXWindow’s handle (Maybe)
  • To intercept the WM_DROPFILES message and extract wParam (Maybe)
  • To work with pointers to pre-allocated buffers. (Yes)

I might be able to hack this up tomorrow, if FXRuby and Fox let me get
low enough access. I know it’s possible in C++, but I can only hope
FXRuby exports enough to intercept messages and get handles.

If I were a Fox hacker, I’d say they should use this simpler API to
emulate Fox’s DND, by sending synthetic messages and making it look like
“text/uri-list”.

···

On Mon, 2003-06-30 at 19:53, Harry Ohlsen wrote:

Hi Tom,

Sorry, I don’t have an answer to your question. I had a quick play with this some time back and didn’t get anywhere.

If you get the code to work under Windows, can you post the final version to the mailing list?

Cheers,

Harry O.


Tom Felker tcfelker@mtco.com

I’ve looked into this further, and I don’t think FXRuby gives low-level
enough access to do this in Ruby. It would be possible for FXRuby to
expose FXApp::dispatchEvent() and FXRawEvent and the window handle, so
it could implemented in Ruby, or for FXRuby to generate fake drag events
itself, but I don’t think Ruby or FXRuby is the right place for this.

To this end, I’ve suggested on the foxgui-users list that FOX itself
should synthesize the drop of a “text/uri-list” when it gets a
WM_DROPFILES.

If they do that, it should make my original code work, in Windows as it
does in Linux.

Have fun,

···

On Mon, 2003-06-30 at 23:35, Tom Felker wrote:

On Mon, 2003-06-30 at 19:53, Harry Ohlsen wrote:

Hi Tom,

Sorry, I don’t have an answer to your question. I had a quick play with this some time back and didn’t get anywhere.

If you get the code to work under Windows, can you post the final version to the mailing list?

Cheers,

Harry O.

Sure, I’ll post any working code I get, but I’m a bit discouraged by my
further research:

http://www.escribe.com/software/foxusers/m4610.html

According to this, on Windows, Fox does DND in it’s own way, not
Window’s way, because OLE is too weird to be cross-platform.
Unfortunately, Windows developers, and certainly Microsoft, won’t jump
to change their DND to work with Fox.

http://www.escribe.com/software/foxusers/m4066.html
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/legacyinformation/shelllib.asp

However, while most of Windows uses OLE or COM or some other hip TLA,
there’s also a special API for file dropping, and this person hacked up
a way to do this in C++. This can be done in plain Ruby and FXRuby,
given the ability:

  • To call Windows functions (Yes)
  • To access a given FXWindow’s handle (Maybe)
  • To intercept the WM_DROPFILES message and extract wParam (Maybe)
  • To work with pointers to pre-allocated buffers. (Yes)

I might be able to hack this up tomorrow, if FXRuby and Fox let me get
low enough access. I know it’s possible in C++, but I can only hope
FXRuby exports enough to intercept messages and get handles.

If I were a Fox hacker, I’d say they should use this simpler API to
emulate Fox’s DND, by sending synthetic messages and making it look like
“text/uri-list”.


Tom Felker tcfelker@mtco.com