#include ;~~~~~~~~~~ constant variable Global Const $PTR_LEN = @AutoItX64 ? 8 : 4 Global Const $S_OK = 0x00000000 Global Const $E_NOTIMPL = 0x80004001 Global Const $E_NOINTERFACE = 0x80004002 Global Const $DRAGDROP_S_DROP = 0x00040100 Global Const $DRAGDROP_S_CANCEL = 0x00040101 Global Const $DRAGDROP_S_USEDEFAULTCURSORS = 0x00040102 Global Const $DRAGDROP_E_NOTREGISTERED = 0x80040100 Global Const $DRAGDROP_E_ALREADYREGISTERED = 0x80040101 Global Const $DROPEFFECT_NONE = 0 Global Const $DROPEFFECT_COPY = 1 Global Const $DROPEFFECT_MOVE = 2 Global Const $DROPEFFECT_LINK = 4 Global Const $DROPEFFECT_SCROLL = 0x80000000 Global Const $MK_LBUTTON = 0x0001 Global Const $MK_RBUTTON = 0x0002 Global Const $MK_SHIFT = 0x0004 Global Const $MK_CONTROL = 0x0008 Global Const $MK_MBUTTON = 0x0010 Global Const $MK_XBUTTON1 = 0x0020 Global Const $MK_XBUTTON2 = 0x0040 ;~~~~~~~~~~ IID Global Const $sIID_IUnknown = "{00000000-0000-0000-C000-000000000046}" Global Const $sIID_IDataObject = "{0000010e-0000-0000-C000-000000000046}" Global Const $sIID_IDropTarget = "{00000122-0000-0000-C000-000000000046}" Global Const $sIID_IDropSource = "{00000121-0000-0000-C000-000000000046}" Global Const $sIID_IDropSourceNotify = "{0000012B-0000-0000-C000-000000000046}" Global Const $sCLSID_DragDropHelper = "{4657278A-411B-11D2-839A-00C04FD918D0}" Global Const $sIID_IDropTargetHelper = "{4657278B-411B-11D2-839A-00C04FD918D0}" ;~~~~~~~~~~ Global Variable Global $g___IDropTarget[0] Global $g___DropSource[0] Global $g___pIDropSourceNotify = 0 Global $g___pIIDropSource = 0 Global $g___DragPoint = 0 Global Const $WM_USER_A = 0x0400 Global Enum $WM_DRAGENTER = $WM_USER_A + 1, $WM_DRAGOVER, $WM_DRAGLEAVE, $WM_DROP ;~~~~~~~~~~ List of commands ; __Cancel_IDropTarget() ; __RegisterDragDrop($hWnd, $pDropTarget) ; __RevokeDragDrop($hWnd) ; __SHDoDragDrop($hGUI, $pDataObj, $pDropSource, $iOKEffects) ; __Initiate_DropSource() ; __Fill_IDataObject(ByRef $sPath) ; __GetFilesFrom_IDataObject($pDataObj) ;~~~~~~~~~~ List of commands Func __Cancel_IDropTarget() If UBound($g___IDropTarget) = 2 Then $g___IDropTarget[0] = 0 __DeleteObjectFromTag($g___IDropTarget[1]) Redim $g___IDropTarget[0] Endif EndFunc Func __RegisterDragDrop($hWnd) If UBound($g___IDropTarget) = 0 Then Redim $g___IDropTarget[2] $g___IDropTarget[0] = __Create_IDropTarget($g___IDropTarget[1]) If Not IsObj($g___IDropTarget[0]) Then SetError(1, 0, 0) Endif Local $aRes = DllCall("ole32.dll", "long", "RegisterDragDrop", "hwnd", $hWnd, "ptr", ($g___IDropTarget[0]())) If @error Then Return SetError(2, 0, $aRes[0]) Return 0 EndFunc Func __RevokeDragDrop($hWnd) Local $aRes = DllCall("ole32.dll", "long", "RevokeDragDrop", "hwnd", $hWnd) If @error Then Return SetError(1, 0, $aRes[0]) Return 0 EndFunc Func __SHDoDragDrop($hGUI, $pDataObj, $pDropSource, $iOKEffects) Local $aCall = DllCall("shell32.dll", "long", "SHDoDragDrop", "hwnd", $hGUI, "ptr", $pDataObj, "ptr", $pDropSource, "dword", $iOKEffects, "ptr*", 0) If @error Then Return SetError(@error, @extended, $aCall) Return SetError($aCall[0], 0, $aCall[4]) EndFunc Func __Initiate_DropSource() ; $g___DropSource[0] = IDropSource (object) ; $g___DropSource[1] = IDropSource (tag) ; $g___DropSource[2] = IDropSourceNotify (object) ; $g___DropSource[3] = IDropSourceNotify (tag) If UBound($g___DropSource) = 4 Then $g___DropSource[0] = 0 __DeleteObjectFromTag($g___DropSource[1]) $g___DropSource[2] = 0 __DeleteObjectFromTag($g___DropSource[3]) $g___pIIDropSource = 0 $g___pIDropSourceNotify = 0 Redim $g___DropSource[0] Return 0 EndIf If UBound($g___DropSource) = 0 Then Redim $g___DropSource[4] $g___DropSource[0] = __Create_IDropSource($g___DropSource[1]) $g___DropSource[2] = __Create_IDropSourceNotify($g___DropSource[3]) $g___DropSource[2].AddRef() Return ($g___DropSource[0]()) ;~~ IDropSource ptr EndFunc Func __Fill_IDataObject(ByRef $sPath) Local $iCount = UBound($sPath) If $iCount = 0 Then Return 0 Local $sParentPath = StringLeft($sPath[0], StringInStr($sPath[0], "\", 0, -1) - 1) Local $pParentPidl = _WinAPI_ShellILCreateFromPath($sParentPath) Local $tPidls = DllStructCreate("ptr[" & $iCount & "]") Local $pFullPidl, $pRelativePidl, $last_SHITEMID For $i = 0 To $iCount - 1 $pFullPidl = _WinAPI_ShellILCreateFromPath($sPath[$i]) $last_SHITEMID = DllCall("shell32.dll", "ptr", "ILFindLastID", "ptr", $pFullPidl)[0] $pRelativePidl = DllCall("shell32.dll", "ptr", "ILClone", "ptr", $last_SHITEMID)[0] DllStructSetData($tPidls, 1, $pRelativePidl, $i + 1) DllCall("shell32.dll", "none", "ILFree", "ptr", $pFullPidl) Next Local $tIID_IDataObject = _WinAPI_GUIDFromString($sIID_IDataObject) Local $pIDataObject = __SHCreateDataObject($tIID_IDataObject, $pParentPidl, $iCount, DllStructGetPtr($tPidls), 0) DllCall("shell32.dll", "none", "ILFree", "ptr", $pParentPidl) For $i = 1 To $iCount DllCall("shell32.dll", "none", "ILFree", "ptr", DllStructGetData($tPidls, 1, $i)) Next If Not $pIDataObject Then Return 0 Return $pIDataObject EndFunc Func __GetFilesFrom_IDataObject($pDataObj) Local $oIDataObject = __Create_IDataObject($pDataObj) If Not IsObj($oIDataObject) Then Return 0 Local $tFORMATETC __Fill_tag_FORMATETC($tFORMATETC) Local $tStgMedium = DllStructCreate("uint tymed;handle hGlobal;ptr pUnkForRelease") Local $hResult = $oIDataObject.GetData(DllStructGetPtr($tFormatEtc), DllStructGetPtr($tStgMedium)) If $hResult = 0 Then Local $hDrop = DllStructGetData($tStgMedium, "hGlobal") Local $nSize, $pFileName Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $hDrop, "int", 0xFFFFFFFF, "ptr", 0, "int", 255) Local $aFiles[$nAmt[0]] For $i = 0 To UBound($aFiles) - 1 $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $hDrop, "int", $i, "ptr", 0, "int", 0) $nSize = $nSize[0] + 1 $pFileName = DllStructCreate("char[" & $nSize & "]") DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $hDrop, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize) $aFiles[$i] = DllStructGetData($pFileName, 1) $pFileName = 0 Next __ReleaseStgMedium(DllStructGetPtr($tStgMedium)) Return $aFiles Endif Return 0 EndFunc ;~~~~~~~~~~ Internal command ; __SendMessage($hWnd, $iMsg, $wParam = 0, $lParam = 0) ; __ReleaseStgMedium($StgMedium) ; __StringFromGUID($pGUID) ; __SHCreateDataObject($tIID_IDataObject, $ppidlFolder = 0, $cidl = 0, $papidl = 0, $pdtInner = 0) ;~ __Create_IDataObject(Byref $pDataObj) ;~ __Create_IDropSource(Byref $tIDropSource) ;~ __Create_IDropSourceNotify(Byref $tIDropSourceNotify) ;~ __Create_IDropTarget(Byref $tIDropTarget) ;~ __Create_DragDropHelper(Byref $oDropHelper) ;~ __Fill_tag_FORMATETC(Byref $tFORMATETC) ;~ __Retrieve_Gui_Handle($pt) ;~ __QueryInterface($pThis, $sIID) ;~ __AddRef($pThis) ;~ __Release($pThis) ;~ __ObjectFromTag($sFunctionPrefix, $tagInterface, ByRef $tInterface, $fPrint = False, $bIsUnknown = Default, $sIID = "{00000000-0000-0000-C000-000000000046}") ;~ __DeleteObjectFromTag(ByRef $tInterface) ;~~~~~~~~~~ Internal command Func __SendMessage($hWnd, $iMsg, $wParam = 0, $lParam = 0) Local $aResult = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam) If @error Then Return SetError(@error, @extended, "") Return $aResult[0] EndFunc Func __ReleaseStgMedium($StgMedium) DllCall("ole32.dll", "long", "ReleaseStgMedium", "ptr", $StgMedium) EndFunc Func __StringFromGUID($pGUID) Local $aResult = DllCall("ole32.dll", "int", "StringFromGUID2", "struct*", $pGUID, "wstr", "", "int", 40) If @error Then Return SetError(@error, @extended, "") Return SetExtended($aResult[0], $aResult[2]) EndFunc Func __SHCreateDataObject($tIID_IDataObject, $ppidlFolder = 0, $cidl = 0, $papidl = 0, $pdtInner = 0) Local $aRes = DllCall("shell32.dll", "long", "SHCreateDataObject", _ "ptr", $ppidlFolder, _ "uint", $cidl, _ "ptr", $papidl, _ "ptr", $pdtInner, _ "struct*", $tIID_IDataObject, _ "ptr*", 0) If @error Then Return SetError(1, 0, $aRes[0]) Return $aRes[6] EndFunc Func __Create_IDataObject(Byref $pDataObj) Local Const $sTagIDataObject = _ "GetData hresult(struct*;struct*);" & _ "GetDataHere hresult(ptr;ptr*);" & _ "QueryGetData hresult(ptr);" & _ "GetCanonicalFormatEtc hresult(ptr;ptr*);" & _ "SetData hresult(ptr;ptr;bool);" & _ "EnumFormatEtc hresult(dword;ptr*);" & _ "DAdvise hresult(ptr;dword;ptr;dword*);" & _ "DUnadvise hresult(dword);" & _ "EnumDAdvise hresult(ptr*);" Return ObjCreateInterface($pDataObj, $sIID_IDataObject, $sTagIDataObject) EndFunc Func __Create_IDropSource(Byref $tIDropSource) Local Const $tag_IDropSource = _ "QueryContinueDrag hresult(BOOL;DWORD);" & _ "GiveFeedback hresult(DWORD);" Return __ObjectFromTag("__IDropSource_", $tag_IDropSource, $tIDropSource, False, True, $sIID_IDropSource) EndFunc Func __Create_IDropSourceNotify(Byref $tIDropSourceNotify) Local Const $tag_IDropSourceNotify = _ "DragEnterTarget hresult(hwnd);" & _ ; IDropSourceNotify 1 "DragLeaveTarget hresult();" ; IDropSourceNotify 2 Return __ObjectFromTag("__IDropSource_", $tag_IDropSourceNotify, $tIDropSourceNotify, False, True, $sIID_IDropSourceNotify) EndFunc Func __Create_IDropTarget(Byref $tIDropTarget) Local Const $tag_IDropTarget = _ "DragEnter hresult(ptr;dword;uint64;dword*);" & _ "DragOver hresult(dword;uint64;dword*);" & _ "DragLeave hresult();" & _ "Drop hresult(ptr;dword;uint64;dword*);" Return __ObjectFromTag("__IDropTarget_", $tag_IDropTarget, $tIDropTarget, False, True, $sIID_IDropTarget) EndFunc Func __Create_DragDropHelper(Byref $oDropHelper) Local $tagIDropTargetHelper = _ "DragEnter hresult(hwnd;ptr;struct*;dword);" & _ "DragLeave hresult();" & _ "DragOver hresult(struct*;dword);" & _ "Drop hresult(ptr;struct*;dword);" & _ "Show hresult(bool);" $oDropHelper = ObjCreateInterface($sCLSID_DragDropHelper, $sIID_IDropTargetHelper, $tagIDropTargetHelper) EndFunc Func __Fill_tag_FORMATETC(Byref $tFORMATETC) Local Const $CF_HDROP = 15 Local Const $TYMED_HGLOBAL = 1 $tFORMATETC = DllStructCreate("ushort cfFormat; ptr ptd; uint dwAspect; int lindex; uint tymed") DllStructSetData($tFORMATETC, "cfFormat", $CF_HDROP) DllStructSetData($tFORMATETC, "dwAspect", 1) DllStructSetData($tFORMATETC, "lindex", -1) DllStructSetData($tFORMATETC, "tymed", $TYMED_HGLOBAL) EndFunc Func __Retrieve_Gui_Handle($pt) Local $tPoint = DllStructCreate($tagPoint) DllStructSetData($tPoint, "X", _WinAPI_LoDWord($pt)) DllStructSetData($tPoint, "Y", _WinAPI_HiDWord($pt)) Local $hWnd = _WinAPI_WindowFromPoint($tPoint) Local $hParent = _WinAPI_GetAncestor($hWnd, 2) ; 2 = $GA_ROOT _WinAPI_ScreenToClient($hParent, $tPoint) Local $hchild = _WinAPI_ChildWindowFromPointEx($hParent, $tPoint) Local $aReturn = [$hParent, $hchild] Return $aReturn EndFunc Func __QueryInterface($pThis, $sIID) Local $pVTab = DllStructGetData(DllStructCreate("ptr", $pThis), 1) Local $pFunc = DllStructGetData(DllStructCreate("ptr", $pVTab), 1) Local $tIID = _WinAPI_GUIDFromString($sIID) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "struct*", $tIID, "ptr*", 0) Return SetError($aCall[0], 0, $aCall[3]) EndFunc ;==>_QueryInterface Func __AddRef($pThis) Local $pVTab = DllStructGetData(DllStructCreate("ptr", $pThis), 1) Local $pFunc = DllStructGetData(DllStructCreate("ptr", $pVTab + $PTR_LEN), 1) Local $aCall = DllCallAddress("uint", $pFunc, "ptr", $pThis) Return $aCall[0] EndFunc ;==>_AddRef Func __Release($pThis) Local $pVTab = DllStructGetData(DllStructCreate("ptr", $pThis), 1) Local $pFunc = DllStructGetData(DllStructCreate("ptr", $pVTab + 2 * $PTR_LEN), 1) Local $aCall = DllCallAddress("uint", $pFunc, "ptr", $pThis) Return $aCall[0] EndFunc ;==>_Release ; #FUNCTION# ============================================================================= ; Name...........: __ObjectFromTag ; ======================================================================================== Func __ObjectFromTag($sFunctionPrefix, $tagInterface, ByRef $tInterface, $fPrint = False, $bIsUnknown = Default, $sIID = "{00000000-0000-0000-C000-000000000046}") ; last param is IID_IUnknown by default If $bIsUnknown = Default Then $bIsUnknown = True Local $sInterface = $tagInterface ; copy interface description Local $tagIUnknown = "QueryInterface hresult(ptr;ptr*);" & _ "AddRef dword();" & _ "Release dword();" ; Adding IUnknown methods If $bIsUnknown Then $tagInterface = $tagIUnknown & $tagInterface ; Below line is really simple even though it looks super complex. It's just written weird to fit in one line, not to steal your attention Local $aMethods = StringSplit(StringReplace(StringReplace(StringReplace(StringReplace(StringTrimRight(StringReplace(StringRegExpReplace(StringRegExpReplace($tagInterface, "\w+\*", "ptr"), "\h*(\w+)\h*(\w+\*?)\h*(\((.*?)\))\h*(;|;*\z)", "$1\|$2;$4" & @LF), ";" & @LF, @LF), 1), ";object", ";idispatch"), "hresult", "long"), "bstr", "ptr"), "variant", "ptr"), @LF, 3) Local $iUbound = UBound($aMethods) Local $sMethod, $aSplit, $sNamePart, $aTagPart, $sTagPart, $sRet, $sParams, $hCallback ; Allocation $tInterface = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[" & $iUbound & "];int_ptr Callbacks[" & $iUbound & "];ulong_ptr Slots[16]") ; 16 pointer sized elements more to create space for possible private props If @error Then Return SetError(1, 0, 0) For $i = 0 To $iUbound - 1 $aSplit = StringSplit($aMethods[$i], "|", 2) If UBound($aSplit) <> 2 Then ReDim $aSplit[2] $sNamePart = $aSplit[0] $sTagPart = $aSplit[1] $sMethod = $sFunctionPrefix & $sNamePart If $fPrint Then Local $iPar = StringInStr($sTagPart, ";", 2), $t If $iPar Then $t = "Ret: " & StringLeft($sTagPart, $iPar - 1) & " " & _ "Par: " & StringRight($sTagPart, StringLen($sTagPart) - $iPar) Else $t = "Ret: " & $sTagPart EndIf Local $s = "Func " & $sMethod & _ "( $pSelf ) ; " & $t & @CRLF & _ "EndFunc" & @CRLF ConsoleWrite($s) EndIf $aTagPart = StringSplit($sTagPart, ";", 2) $sRet = $aTagPart[0] $sParams = StringReplace($sTagPart, $sRet, "", 1) $sParams = "ptr" & $sParams $hCallback = DllCallbackRegister($sMethod, $sRet, $sParams) If @error Then ConsoleWrite('![@error] ' & @error & ' ' & $sMethod & @CRLF & @CRLF) EndIf DllStructSetData($tInterface, "Methods", DllCallbackGetPtr($hCallback), $i + 1) ; save callback pointer DllStructSetData($tInterface, "Callbacks", $hCallback, $i + 1) ; save callback handle Next DllStructSetData($tInterface, "RefCount", 1) ; initial ref count is 1 DllStructSetData($tInterface, "Size", $iUbound) ; number of interface methods DllStructSetData($tInterface, "Object", DllStructGetPtr($tInterface, "Methods")) ; Interface method pointers Return ObjCreateInterface(DllStructGetPtr($tInterface, "Object"), $sIID, $sInterface, $bIsUnknown) ; pointer that's wrapped into object EndFunc ; #FUNCTION# ============================================================================= ; Name...........: __DeleteObjectFromTag ; ======================================================================================== Func __DeleteObjectFromTag(ByRef $tInterface) For $i = 1 To DllStructGetData( $tInterface, "Size" ) DllCallbackFree( DllStructGetData( $tInterface, "Callbacks", $i ) ) Next $tInterface = 0 EndFunc ;~~~~~~~~~~~~~~~~~~~~~~~~ IDropTarget Func __IDropTarget_QueryInterface($pSelf, $pRIID, $pObj) Local $sIID = __StringFromGUID($pRIID) If $sIID = $sIID_IUnknown Or $sIID = $sIID_IDropTarget Then DllStructSetData(DllStructCreate("ptr", $pObj), 1, $pSelf) __IDropTarget_AddRef($pSelf) Return 0 ; S_OK EndIf DllStructSetData(DllStructCreate("ptr", $pObj), 1, 0) Return 0x80004002 ; E_NOINTERFACE EndFunc Func __IDropTarget_AddRef($pSelf) Local $tRef = DllStructCreate("int", $pSelf - 8) ; reference counter is size of two ints before Local $iRef = DllStructGetData($tRef, 1) + 1 ; increment DllStructSetData($tRef, 1, $iRef) Return $iRef EndFunc Func __IDropTarget_Release($pSelf) Local $tRef = DllStructCreate("int", $pSelf - 8) ; reference counter is size of two ints before Local $iRef = DllStructGetData($tRef, 1) - 1 ; decrement DllStructSetData($tRef, 1, $iRef) Return $iRef EndFunc Func __IDropTarget_DragEnter($pSelf, $pDataObj, $grfKeyState, $pt, $pdwEffect) Local $oDropHelper __Create_DragDropHelper($oDropHelper) If IsObj($oDropHelper) Then Local $tPoint = DllStructCreate($tagPoint) DllStructSetData($tPoint, "X", _WinAPI_LoDWord($pt)) DllStructSetData($tPoint, "Y", _WinAPI_HiDWord($pt)) Local $hWnd = __Retrieve_Gui_Handle($pt) Local $TargethWnd = (($hWnd[1] = 0x00000000) ? $hWnd[0] : $hWnd[1]) $oDropHelper.DragEnter($hWnd[0], $pDataObj, $tPoint, DllStructGetData(DllStructCreate("dword", $pdwEffect), 1)) ; __SendMessage($hWnd[0], $WM_DRAGENTER, $TargethWnd, $pDataObj) EndIf $oDropHelper = 0 Return 0 EndFunc Func __IDropTarget_DragOver($pSelf, $grfKeyState, $pt, $pdwEffect) Local $oDropHelper __Create_DragDropHelper($oDropHelper) If IsObj($oDropHelper) Then Local $tPoint = DllStructCreate($tagPoint) DllStructSetData($tPoint, "X", _WinAPI_LoDWord($pt)) DllStructSetData($tPoint, "Y", _WinAPI_HiDWord($pt)) $oDropHelper.DragOver($tPoint, DllStructGetData(DllStructCreate("dword", $pdwEffect), 1)) EndIf $oDropHelper = 0 Return 0 EndFunc Func __IDropTarget_DragLeave($pSelf) Local $oDropHelper __Create_DragDropHelper($oDropHelper) If IsObj($oDropHelper) Then $oDropHelper.DragLeave() EndIf $oDropHelper = 0 Return 0 EndFunc Func __IDropTarget_Drop($pSelf, $pDataObj, $grfKeyState, $pt, $pdwEffect) Local $oDropHelper __Create_DragDropHelper($oDropHelper) If IsObj($oDropHelper) Then Local $hWnd = __Retrieve_Gui_Handle($pt) Local $TargethWnd = (($hWnd[1] = 0x00000000) ? $hWnd[0] : $hWnd[1]) Local $tPoint = DllStructCreate($tagPoint) DllStructSetData($tPoint, "X", _WinAPI_LoDWord($pt)) DllStructSetData($tPoint, "Y", _WinAPI_HiDWord($pt)) $oDropHelper.Drop($pDataObj, DllStructGetPtr($tPoint), DllStructGetData(DllStructCreate("dword", $pdwEffect), 1)) If $g___DragPoint <> $TargethWnd Then __SendMessage($hWnd[0], $WM_DROP, $TargethWnd, $pDataObj) $g___DragPoint = 0 EndIf $oDropHelper = 0 Return 0 EndFunc ;~~~~~~~~~~~~~~~~~~~~~~~~ IDropSource Func __IDropSource_QueryInterface($pSelf, $pRIID, $pObj) Local $sIID = __StringFromGUID($pRIID) Local $tPtr = DllStructCreate("ptr", $pObj) ;~~ Handle IDropSource If $sIID = $sIID_IUnknown Then DllStructSetData($tPtr, 1, $pSelf) __IDropSource_AddRef($pSelf) Return 0 ; S_OK EndIf ;~~ Handle IDropSource If $sIID = $sIID_IDropSource Then If $g___pIIDropSource = 0 Then $g___pIIDropSource = $pSelf DllStructSetData($tPtr, 1, $g___pIIDropSource) __IDropSource_AddRef($pSelf) Return 0 ; S_OK EndIf ;~~ Handle IDropSourceNotify If $sIID = $sIID_IDropSourceNotify Then If $g___pIDropSourceNotify = 0 Then $g___pIDropSourceNotify = $pSelf DllStructSetData($tPtr, 1, $g___pIDropSourceNotify) __IDropSource_AddRef($pSelf) Return 0 ; S_OK EndIf DllStructSetData($tPtr, 1, 0) Return 0x80004002 ; E_NOINTERFACE EndFunc Func __IDropSource_AddRef($pSelf) Local $tRef = DllStructCreate("int", $pSelf - 8) ; reference counter is size of two ints before Local $iRef = DllStructGetData($tRef, 1) + 1 ; increment DllStructSetData($tRef, 1, $iRef) Return $iRef EndFunc Func __IDropSource_Release($pSelf) Local $tRef = DllStructCreate("int", $pSelf - 8) ; reference counter is size of two ints before Local $iRef = DllStructGetData($tRef, 1) - 1 ; decrement DllStructSetData($tRef, 1, $iRef) Return $iRef EndFunc Func __IDropSource_QueryContinueDrag($pSelf, $fEscapePressed, $grfKeyState) Local $iReturn = $S_OK ; Default to continuing the drag IF $g___DragPoint = 0 Then Local $tPoint = DllStructCreate($tagPoint) DllStructSetData($tPoint, "X", MouseGetPos(0)) DllStructSetData($tPoint, "Y", MouseGetPos(1)) $g___DragPoint = _WinAPI_WindowFromPoint($tPoint) EndIf If $fEscapePressed Then $iReturn = $DRAGDROP_S_CANCEL $g___DragPoint = 0 Else If Not BitAND($grfKeyState, BitOR($MK_LBUTTON, $MK_RBUTTON)) Then $iReturn = $DRAGDROP_S_DROP Local $tPoint = DllStructCreate($tagPoint) DllStructSetData($tPoint, "X", MouseGetPos(0)) DllStructSetData($tPoint, "Y", MouseGetPos(1)) Local $TargethWnd = _WinAPI_WindowFromPoint($tPoint) IF $TargethWnd <> $g___DragPoint Then $g___DragPoint = 0 EndIf EndIf Return $iReturn ; MUST return the status, not 0 EndFunc Func __IDropSource_GiveFeedback($pSelf, $dwEffect) Return $DRAGDROP_S_USEDEFAULTCURSORS EndFunc ;~~~~~~~~~~~~~~~~~~~~~~~~ IDropSourceNotify Func __IDropSource_DragEnterTarget($pSelf, $hWndTarget) Return 0 ; S_OK EndFunc Func __IDropSource_DragLeaveTarget($pSelf) Return 0 ; S_OK EndFunc