TheDcoder Posted May 20, 2015 Share Posted May 20, 2015 Hello, I need to track multiple drag n drops. When I drop 2 files in my GUI, @GUI_DragFile only returns 1 file Here is the GUI for you work on :#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 282, 142, -1, BitOR($WS_EX_ACCEPTFILES,$WS_EX_WINDOWEDGE)) $Edit1 = GUICtrlCreateEdit("", 0, 0, 601, 433) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUICtrlSetData(-1, "Edit1") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED MsgBox(48, "Dropped", '@GUI_DragId = ' & @GUI_DragId & @CRLF & '@GUI_DragFile = ' & @GUI_DragFile & @CRLF & '@GUI_DropId = ' & @GUI_DropId) EndSwitch WEnd ; In this case, the edit control populates with dropped files's paths. Please don't use GUICtrlRead to read the file paths, Pretend that the edit ctrl is emptyThanks in Advance, TD EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
UEZ Posted May 20, 2015 Share Posted May 20, 2015 (edited) Checkout _WinAPI_DragQueryFileEx in the help file. Edited May 20, 2015 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
TheDcoder Posted May 20, 2015 Author Share Posted May 20, 2015 (edited) Thanks UEZ, But what should I pass for $hDrop? The example does very complex things Edited May 20, 2015 by TheDcoder EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 20, 2015 Moderators Share Posted May 20, 2015 TheDcoder,I use the code in this post to deal with multiple drops.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
UEZ Posted May 20, 2015 Share Posted May 20, 2015 (edited) The example is using callbacks for getting the drag and drop events. In this case it uses callback for the triggering.The $hDrop is the $wParam value from the WinProc callback function.An example using WM messages:expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPISys.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 282, 142, -1, BitOR($WS_EX_ACCEPTFILES,$WS_EX_WINDOWEDGE)) $Edit1 = GUICtrlCreateEdit("", 0, 0, 601, 433) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUICtrlSetData(-1, "Edit1") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED MsgBox(48, "Dropped", '@GUI_DragId = ' & @GUI_DragId & @CRLF & '@GUI_DragFile = ' & @GUI_DragFile & @CRLF & '@GUI_DropId = ' & @GUI_DropId) EndSwitch WEnd Func WM_DROPFILES($hwnd, $msg, $wParam, $lParam) #forceref $hWnd, $Msg, $lParam Local $sFileList = _WinAPI_DragQueryFileEx($wParam) If Not @error Then For $i = 1 To $sFileList[0] ConsoleWrite($sFileList[$i] & @CRLF) Next _WinAPI_DragFinish($wParam) Return 0 EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>WM_DROPFILES Edited May 20, 2015 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
TheDcoder Posted May 20, 2015 Author Share Posted May 20, 2015 Thanks UEZ , But why is $DROP_ACCEPTED not executed? EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
UEZ Posted May 20, 2015 Share Posted May 20, 2015 (edited) Because of GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES"). Either GUIGetMsg() or GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES"), not both together. Edited May 20, 2015 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
TheDcoder Posted May 20, 2015 Author Share Posted May 20, 2015 Thanks P.S Now I use a button to select multiple files b/c dnd looks complicated EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
kylomas Posted May 21, 2015 Share Posted May 21, 2015 TheDcoder,Don't short change yourself. Look at the following simple code...expandcollapse popup#include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPISys.au3> #include <array.au3> #AutoIt3Wrapper_Add_Constants=n $hGui010 = GUICreate("", 500, 200, -1, -1, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_WINDOWEDGE)) $lbl010 = GUICtrlCreateLabel("", 10, 10, 480, 180, $SS_SUNKEN) GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; dummy control to action when files are droppd on $lbl010 $FilesDropped = GUICtrlCreateDummy() GUISetState(@SW_SHOW) GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $FilesDropped ConsoleWrite('LBL010 has files to process' & @CRLF) ; ; code to process files in this case just populate an array ; _arraydisplay(stringsplit(guictrlread($lbl010),@CRLF,3),'Files Dropped on $lbl010') EndSwitch WEnd Func WM_DROPFILES($hwnd, $msg, $wParam, $lParam) Local $sFileList = _WinAPI_DragQueryFileEx($wParam), $str If Not @error Then For $i = 1 To $sFileList[0] $str &= $sFileList[$i] & @CRLF Next _WinAPI_DragFinish($wParam) GUICtrlSetData($lbl010, $str & @CRLF) ; populate $lbl010 GUICtrlSendToDummy($FilesDropped) ; send message to action $FilesDropped Return 0 EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>WM_DROPFILESkylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
TheDcoder Posted May 22, 2015 Author Share Posted May 22, 2015 @kylomas Thanks! . Now I understanding the purpose of dummy control EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion 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