其实 你可以去看看帮助文件夹里的源码
;请参考autoit3\Examples\WinAPIEx\_WinAPI_DragAcceptFiles.au3 略作修改
#Include <Constants.au3>
#Include <GUIConstantsEx.au3>
#Include <WindowsConstants.au3>
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Global Const $WM_DROPFILES = 0x0233
Global $hForm, $Msg, $Check, $Input1, $hInput1, $hDll, $pDll, $hProc
OnAutoItExitRegister('OnAutoItExit')
; Create GUI
$hForm = GUICreate('文本框接受拖拽文件得到路径', 400, 200)
$Input1 = GUICtrlCreateInput("Input1", 64, 64, 321, 21)
$hInput1 = GUICtrlGetHandle($Input1)
; Register label window proc
$hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam')
$pDll = DllCallbackGetPtr($hDll)
$hProc = _WinAPI_SetWindowLong($hInput1, $GWL_WNDPROC, $pDll)
_WinAPI_DragAcceptFiles($hInput1, True)
GUISetState()
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case -3
ExitLoop
EndSwitch
WEnd
Func _WinProc($hWnd, $iMsg, $wParam, $lParam)
Local $str
Switch $iMsg
Case $WM_DROPFILES
Local $FileList = _WinAPI_DragQueryFileEx($wParam)
If IsArray($FileList) Then
$str = ""
For $i = 1 To $FileList[0]
$str &= $FileList[$i] & @CRLF
Next
GUICtrlSetData($Input1, $str)
EndIf
_WinAPI_DragFinish($wParam)
Return 0
EndSwitch
Return _WinAPI_CallWindowProc($hProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc ;==>_WinProc
Func OnAutoItExit()
_WinAPI_SetWindowLong($hInput1, $GWL_WNDPROC, $hProc)
DllCallbackFree($hDll)
EndFunc ;==>OnAutoItExit
|