momar33 Posted October 3, 2007 Share Posted October 3, 2007 I am just trying to get a console message when i drop something on my gui, it won't work. #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) $gui = GUICreate("My GUI", Default, Default, Default, Default, Default, $WS_EX_ACCEPTFILES) ;GUICtrlSetState ($gui, $GUI_DROPACCEPTED) GUISetOnEvent($GUI_EVENT_DROPPED, "Dropped", $gui) GUISetState() While 1 Sleep(100) WEnd Func Dropped() Consolewrite("----" & @GUI_DragFile & @CRLF) EndFunc Link to comment Share on other sites More sharing options...
JBeef Posted October 3, 2007 Share Posted October 3, 2007 try control - not gui. ~Jap Link to comment Share on other sites More sharing options...
Siao Posted October 3, 2007 Share Posted October 3, 2007 (edited) Like JBeef said, normally in AutoIt you need to create control with $GUI_DROPACCEPTED, and drag onto it. But since you're so nonconformist, here's how to have drag and drop on whole GUI: expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) $gui = GUICreate("My GUI", Default, Default, Default, Default, Default, $WS_EX_ACCEPTFILES) ;~ GUISetOnEvent($GUI_EVENT_DROPPED, "Dropped", $gui) ;we don't need this GUISetState() ;~ Const $WM_DROPFILES = 0x233 GUIRegisterMsg(0x233, "On_WM_DROPFILES") While 1 Sleep(100) WEnd Func On_WM_DROPFILES($hWnd, $Msg, $wParam, $lParam) Local $tDrop, $aRet, $iCount ;string buffer for file path $tDrop = DllStructCreate("char[260]") ;get file count $aRet = DllCall("shell32.dll", "int", "DragQueryFile", _ "hwnd", $wParam, _ "uint", -1, _ "ptr", DllStructGetPtr($tDrop), _ "int", DllStructGetSize($tDrop) _ ) $iCount = $aRet[0] ;get file paths For $i = 0 To $iCount-1 $aRet = DllCall("shell32.dll", "int", "DragQueryFile", _ "hwnd", $wParam, _ "uint", $i, _ "ptr", DllStructGetPtr($tDrop), _ "int", DllStructGetSize($tDrop) _ ) ConsoleWrite(DllStructGetData($tDrop, 1) & @CRLF) Next ;finalize DllCall("shell32.dll", "int", "DragFinish", "hwnd", $wParam) Return EndFunc Edited October 3, 2007 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
JBeef Posted October 3, 2007 Share Posted October 3, 2007 sweet nibbrets - crazy - ~Jap Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now