Drag and Drop in Windows with Explorer

T

Tom Felker

--=-T+JD42+kFl7VYWdJPGTV
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

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,
--
Tom Felker <[email protected]>

--=-T+JD42+kFl7VYWdJPGTV
Content-Disposition: attachment; filename=filedropper.rb
Content-Type: text/plain; name=filedropper.rb; charset=iso-8859-1
Content-Transfer-Encoding: 7bit

#!/usr/bin/env ruby

require "fox"
include Fox

class FileDropper < FXMainWindow

def initialize(app)
super(app, "FileDropper", nil, nil, DECOR_ALL, 0, 0, 200, 150)
dropEnable

connect(SEL_DND_DROP) do
puts "\nSEL_DND_DROP"
puts getDNDData(FROM_DRAGNDROP, FXWindow.urilistType)
end

connect(SEL_DND_MOTION) do
puts "\nSEL_DND_MOTION"
inquireDNDTypes(FROM_DRAGNDROP).each do |t|
puts getApp().getDragTypeName(t)
end
if offeredDNDType?(FROM_DRAGNDROP, FXWindow.urilistType)
acceptDrop
end
end

end

def create
super
FXWindow.urilistType = getApp().registerDragType(FXWindow.urilistTypeName)
show(PLACEMENT_SCREEN)
end
end

app = FXApp.new("FileDropper", "FXRuby")
FileDropper.new(app)
app.create
app.run


--=-T+JD42+kFl7VYWdJPGTV--
 
H

Harry Ohlsen

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.
 
T

Tom Felker

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/d...ogrammersguide/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".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top