Windows drag & drop with win32com and IDropTarget
Tim Golden
mail at timgolden.me.uk
Fri Jan 15 03:36:49 EST 2010
On 15/01/2010 07:20, Greg K wrote:
> I'm trying to create a program that will process files dragged into
> its window, however I can't seem to get the cursor to change correctly
> when something is dragged over the window. I've created an object that
> implements the IDropTarget interface, but it seems the value returned
> by its DragEnter method is ignored by Windows. No matter what value it
> returns, I always get a "create shortcut" cursor when something is
> dragged over the window.
This is a segment of my code which works ok:
<... code snippet ...>
def DragEnter (self, data_object, key_state, point, effect):
ur"""Query the data block for a drag action which is over the dialog.
If we can handle it, indicate that we're ready to accept a drop from
this data.
"""
try:
data_object.QueryGetData (self._data_format)
except pywintypes.error:
return shellcon.DROPEFFECT_NONE
else:
return shellcon.DROPEFFECT_COPY
<... code snippet ...>
The whole code's here if you want:
https://winsys.googlecode.com/svn/trunk/winsys/dialogs.py
It looks as though you're returning an OK *and* the effect
which isn't how the thing is implemented via the pywin32
wrappers.
TJG
More information about the Python-list
mailing list