Sign in to follow this  
Followers 0
momar33

Can't get files dropped onto gui to be accepted.

4 posts in this topic

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

Share this post


Link to post
Share on other sites



try control - not gui. ~Jap

Share this post


Link to post
Share on other sites

#3 ·  Posted (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:

#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 by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

sweet nibbrets - crazy - ~Jap

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0