Search the Community
Showing results for tags 'dragquerypoint'.
-
I spent few hours trying to figure out how to get results from the _WinAPI_DragQueryPoint when the script runs on elevated rights with a WM_DROPFILES registered message. I searched everywhere but I wasn't able to find the right message to allow on my GUI. So I finally decided to allow all messages under 0x400, to finally find THE ONE that makes it work. It was really a surprise to find out that it is $WM_NCHITTEST !!! To test you start Windows Explorer and you simply Drag & Drop anywhere into the GUI. If you remove any of the _WinAPI_ChangeWindowMessageFilterEx it will not fully work. Anyway since I was not able to find it on the Web may as well document it here. #include <GUIConstantsEx.au3> #include <WinAPIEx.au3> #include <WindowsConstants.au3> #RequireAdmin Global $hGUI = GUICreate('WM_DROPFILES', 400, 200, -1, -1, -1, $WS_EX_ACCEPTFILES) GUISetState() GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES") _WinAPI_ChangeWindowMessageFilterEx($hGUI, $WM_NCHITTEST, $MSGFLT_ALLOW) _WinAPI_ChangeWindowMessageFilterEx($hGUI, $WM_DROPFILES, $MSGFLT_ALLOW) _WinAPI_ChangeWindowMessageFilterEx($hGUI, $WM_COPYGLOBALDATA, $MSGFLT_ALLOW) ;_WinAPI_ChangeWindowMessageFilterEx ($hGUI, $WM_COPYDATA, $MSGFLT_ALLOW) ; useless ? While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $aFileList Switch $hWnd Case $hGUI $tPoint = _WinAPI_DragQueryPoint($wParam) $iXpos = DllStructGetData($tPoint, 1) $iYpos = DllStructGetData($tPoint, 2) ConsoleWrite ($iXpos & "/" & $iYpos & @CRLF) $aFileList = _WinAPI_DragQueryFileEx($wParam) If IsArray($aFileList) Then For $i = 1 To $aFileList[0] ConsoleWrite($aFileList[$i] & @CRLF) Next EndIf _WinAPI_DragFinish($wParam) Return 0 EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_DROPFILES Tested on Win7.