Sign in to follow this  
Followers 0
TuMiM

Drag and Drop files multiple

6 posts in this topic

I have a gui with two label boxes which can have files dropped on them. I used code i found on the forums for the drag and drop (can't remember whose code it was, sorry). How do I write the code so that it knows which box the file is being dropped on so it can run two different actions, depending on which box it's dropped onto. Thanks

#include <GUIConstants.au3>

Global $WM_DROPFILES = 0x233
Global $gaDropFiles[1], $str = ""

$hGUI = GUICreate("Test", 400, 200, 219, 178, -1, $WS_EX_ACCEPTFILES)
$hList = GUICtrlCreateLabel("Drag files that are to be converted to a secure PDF - no printing, copying allowed", 5, 5, 100, 100, $SS_SUNKEN)
$hList1 = GUICtrlCreateLabel("Drag files that are to be converted to a PDF", 130, 5, 100, 100, $SS_SUNKEN)
GUICtrlSetState (-1, $GUI_DROPACCEPTED)
GUISetState(@SW_SHOW)

GUIRegisterMsg ($WM_DROPFILES, "WM_DROPFILES_FUNC")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_DROPPED
            $str = ""
            For $i = 0 To UBound($gaDropFiles) - 1
                Filecopy($gaDropFiles[$i],"\\mianfiler01\dla$\pdf convert\secure\inbox")
                run("explorer.exe \\mianfiler01\dla$\pdf convert\secure\outbox")
            Next
    EndSwitch
WEnd

Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam)
    Local $nSize, $pFileName
    Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
    For $i = 0 To $nAmt[0] - 1
        $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0)
        $nSize = $nSize[0] + 1
        $pFileName = DllStructCreate("char[" & $nSize & "]")
        DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
        ReDim $gaDropFiles[$i+1]
        $gaDropFiles[$i] = DllStructGetData($pFileName, 1)
        $pFileName = 0
    Next
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Look up GUICtrlSetState in the manual for info on @GUI_DROPID.

Gafrost (as I understand it) is the author of the drop script you're using.

I have written out a small example. Your key is @GUI_DropID

Func dragDrop()
     Switch @GUI_DROPID ;<> ---- the name of ctrl that the file was dropped into
        Case $hList
            MsgBox(0,'','drag list 1') ; <> ---  remove when you set it up
            #cs
            $str = ""
            For $i = 0 To UBound($gaDropFiles) - 1
                
                Filecopy($gaDropFiles[$i],"\\mianfiler01\dla$\pdf convert\secure\inbox")
                run("explorer.exe \\mianfiler01\dla$\pdf convert\secure\outbox")
            Next            
            #ce
        Case $hList1
            MsgBox(0,'','drag list 2')
    EndSwitch
EndFunc

Edit: Clarified first statement

Edited by JohnBailey

A decision is a powerful thing

Share this post


Link to post
Share on other sites

Thanks. If i add your code in then when i drop a file on the hlist1 label it shows me the msgbox but when i drop it on the hlist label it does nothing.

Share this post


Link to post
Share on other sites

I figured it out. nevermind. Thanks

Thanks. If i add your code in then when i drop a file on the hlist1 label it shows me the msgbox but when i drop it on the hlist label it does nothing.

Share this post


Link to post
Share on other sites

Thanks. If i add your code in then when i drop a file on the hlist1 label it shows me the msgbox but when i drop it on the hlist label it does nothing.

$hList = GUICtrlCreateLabel("Drag files that are to be converted to a secure PDF - no printing, copying allowed", 5, 5, 100, 100, $SS_SUNKEN)
$hList1 = GUICtrlCreateLabel("Drag files that are to be converted to a PDF", 130, 5, 100, 100, $SS_SUNKEN)
GUICtrlSetState (-1, $GUI_DROPACCEPTED)  ;<<---- is whyoÝ÷ Ú&(ºf²z0¶¬þ+a{Yj{-éZ²×-®!Èb³Mú¸¬·V®¶­s`¤uT7G&Å6WE7FFRb33c¶Æ7BÂb33c´uTôE$õ44UDTB¤uT7G&Å6WE7FFRb33c¶Æ7CÂb33c´uTôE$õ44UDTB

A decision is a powerful thing

Share this post


Link to post
Share on other sites

awesome! Glad you got it all working


A decision is a powerful thing

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