TuMiM Posted March 21, 2007 Posted March 21, 2007 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 expandcollapse popup#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
JohnBailey Posted March 21, 2007 Posted March 21, 2007 (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_DropIDFunc 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 EndFuncEdit: Clarified first statement Edited March 21, 2007 by JohnBailey A decision is a powerful thing
TuMiM Posted March 21, 2007 Author Posted March 21, 2007 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.
TuMiM Posted March 21, 2007 Author Posted March 21, 2007 I figured it out. nevermind. ThanksThanks. 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.
JohnBailey Posted March 21, 2007 Posted March 21, 2007 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
JohnBailey Posted March 21, 2007 Posted March 21, 2007 awesome! Glad you got it all working A decision is a powerful thing
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