 : filecount-from-data-object ( data-object -- n )
     \ filecount-from-hdrop swap handle-data-object ;
 
-TUPLE: listener-dragdrop hWnd last-drop-effect ;
+TUPLE: listener-dragdrop world last-drop-effect ;
 
-: <listener-dragdrop> ( hWnd -- object )
+: <listener-dragdrop> ( world -- object )
     DROPEFFECT_NONE listener-dragdrop boa ;
 
 <<

USING: accessors alien.accessors alien.data alien.strings
classes.struct io.encodings.utf16n kernel make math namespaces
prettyprint sequences specialized-arrays
ui.gadgets.worlds ui.tools.listener windows.com
windows.com.wrapper windows.dropfiles windows.kernel32
windows.ole32 windows.shell32 windows.types ;
SPECIALIZED-ARRAY: WCHAR
IN: windows.dragdrop-listener


>>

: dragdrop-listener-window ( -- )
    world get dup <listener-dragdrop>
    +listener-dragdrop-wrapper+ get-global com-wrap [
        [ handle>> hWnd>> ] dip
        2dup RegisterDragDrop dup E_OUTOFMEMORY =
        [ drop ole-initialize RegisterDragDrop ] [ 2nip ] if
        check-ole32-error
