#include #include #include Global $aFileList, $lastDragID $hGUI = GUICreate("Independent control multi file drag", 565, 247, -1, -1, -1, $WS_EX_WINDOWEDGE) $Input1 = GUICtrlCreateInput("", 32, 16, 505, 121) ; Now only here the drop sign appears $defpic1 = "C:\Windows\Web\Wallpaper\Spotlight\img50.jpg" ;win11壁纸1 $defpic2 = "C:\Windows\Web\Wallpaper\Windows\img19.jpg" ;win11壁纸2 $defpic = "" For $i = 1 To 5 If Random(0, 1, 1) Then $defpic = $defpic1 Else $defpic = $defpic2 EndIf Assign("Pic" & $i & "Handle", GUICtrlCreatePic($defpic, 20 + (($i - 1) * 100), 180, 90, 50, -1, $WS_EX_ACCEPTFILES)) GUICtrlSetState(Eval("Pic" & $i & "Handle"), $GUI_DROPACCEPTED) Next GUICtrlSetState(-1, $GUI_DROPACCEPTED) Global $idDummy = GUICtrlCreateDummy() GUISetState() $wProcHandle = DllCallbackRegister("_WindowProc", "ptr", "hwnd;uint;wparam;lparam") For $i = 1 To 5 Assign("gchp" & $i, GUICtrlGetHandle(Eval("Pic" & $i & "Handle"))) Assign("wProcOld" & $i, _WinAPI_SetWindowLong(Eval("gchp" & $i), $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle))) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idDummy For $i = 1 To $aFileList[0] ConsoleWrite($aFileList[$i] & @CRLF) ;拖放处理文件段 Next GUICtrlSetData($Input1, $lastDragID & "##" & _ArrayToString($aFileList, "|", 1)) For $i = 1 To 5 If Eval("gchp" & $i) = $lastDragID Then MsgBox(0, "idP-" & $i, _ArrayToString($aFileList, @CRLF, 1)) Next EndSwitch WEnd GUIDelete($hGUI) DllCallbackFree($wProcHandle) Func _WindowProc($hWnd, $Msg, $wParam, $lParam) For $j = 1 To 5 ;拖放识别控件段 If $hWnd = GUICtrlGetHandle(Eval("Pic" & $j & "Handle")) Then isDrag($hWnd, $Msg, $wParam, $lParam, Eval("wProcOld" & $j)) Next EndFunc ;==>_WindowProc Func isDrag($hWnd2, $Msg2, $wParam2, $lParam2, $wProcOldx) If $Msg2 = $WM_DROPFILES Then $lastDragID = $hWnd2 ConsoleWrite($lastDragID & @CRLF) $aFileList = _WinAPI_DragQueryFileEx($wParam2) If Not @error Then GUICtrlSendToDummy($idDummy) _WinAPI_DragFinish($wParam2) Return 0 Else Return _WinAPI_CallWindowProc($wProcOldx, $hWnd2, $Msg2, $wParam2, $lParam2) ;放行相应控件的其它消息 EndIf EndFunc ;==>isDrag