Sign in to follow this  
Followers 0
antiufo

Accept drag'n'drop on the whole window

2 posts in this topic

How can I create a GUI that:

* Has no input controls

* Accepts dropped files everywhere

* when a file is dropped on any point of the window, call a function with the path of the file as parameter?

thanks.


Share this post


Link to post
Share on other sites



Cover your GUI with a disabled transparent label and use the label to register the drop.eg:

#include <GUIConstants.au3>

$Gui = GUICreate("Drop 'N' ShellExecute", 300, 200, -1, -1, -1, $WS_EX_ACCEPTFILES + $WS_EX_TOPMOST)
$CatchDrop = GUICtrlCreateLabel("", -1, -1, 300, 200)
GUICtrlSetState(-1, $GUI_DISABLE + $GUI_DROPACCEPTED)
GUISetState(@SW_SHOW, $Gui)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $GUI_EVENT_DROPPED
            If StringRight(@GUI_DRAGFILE, 4) = ExtFilter(StringRight(@GUI_DRAGFILE, 4)) Then
                ShellExecute(@GUI_DRAGFILE)
            EndIf
    EndSelect
WEnd

Func ExtFilter($iExt)
    $SSEXT = StringSplit(".exe|.jpg|.mp3|.txt", "|")
    For $i = 1 To $SSEXT[0]
        If $SSEXT[$i] = $iExt Then Return $iExt
    Next
    Return 0
EndFunc

Cheers

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