AutoXenon Posted January 17, 2023 Share Posted January 17, 2023 (edited) MessageLoop: GUICreate('') GUICtrlSetState(GUICtrlCreateEdit('Drop Here',0,0,400,400,-1,0x00000010),8) GUISetState() While 1 Switch GUIGetMsg() Case -3 Quit() Case -13 Drop() EndSwitch WEnd Func Quit() Exit EndFunc Func Drop() MsgBox(0,'','drop') EndFunc OnEvent: Opt('GUIOnEventMode',1) GUICreate('') GUICtrlSetState(GUICtrlCreateEdit('Drop Here',0,0,400,400,-1,0x00000010),8) GUISetOnEvent(-3,Quit) GUISetOnEvent(-13,Drop) GUISetState() While Sleep(1000) WEnd Func Quit() Exit EndFunc Func Drop() MsgBox(0,'','drop') EndFunc Edited January 17, 2023 by AutoXenon Link to comment Share on other sites More sharing options...
AutoBert Posted January 17, 2023 Share Posted January 17, 2023 Helpfile says.: will only work with Quote Extended Style result $WS_EX_ACCEPTFILES Allow an edit or input control within the created GUI window to receive filenames via drag and drop. The control must have also the $GUI_DROPACCEPTED state set by GUICtrlSetState(). for other controls the drag&drop info can be retrieved with @GUI_DragId, @GUI_DragFile, @GUI_DropId. Read example for GUICtrlCreateInput. pixelsearch 1 Link to comment Share on other sites More sharing options...
AutoXenon Posted January 17, 2023 Author Share Posted January 17, 2023 (edited) Please read the code, you'll notice that I've done all that with how I created the controls. It might occasionally be productive to actually try the code yourself, in my experience. Edited January 17, 2023 by AutoXenon Link to comment Share on other sites More sharing options...
AutoBert Posted January 17, 2023 Share Posted January 17, 2023 I read in Code GuiCtrlReadButton but and i know the example to GuiCtrlCreateInput works. So Read the Helfile. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 17, 2023 Moderators Share Posted January 17, 2023 AutoXenon, Quote It might occasionally be productive to actually try the code yourself, in my experience. Charming - please do try and keep it civil from now on Now go and look carefully at the example in the Help file for GUICtrlCreateInput and see where the $WS_EX_ACCEPTFILES extended style should be placed (Hint: not where you have it). M23 pixelsearch, AutoXenon and AutoBert 3 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...
AutoXenon Posted January 17, 2023 Author Share Posted January 17, 2023 (edited) Charmingly ironic indeed, given the forum's reputation -- I suppose the definition of incivility does not extend to the regular condescending dismissals palpable here -- especially when actively encouraged and perpetrated by the very keepers of civility. In any case, if you would kindly read the documentation being referred to, GUICtrlCreateEdit/Input/whatever have seven positional arguments. I suppose if you mentally counted using zero-based indexing then that might explain the confusion. If one had indeed attempted to run the code, you may notice that the cursor correctly changes to that corresponding to drag-and-drop, whereas excluding it results in the disabled cursor instead. Edited January 17, 2023 by AutoXenon Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 17, 2023 Moderators Share Posted January 17, 2023 AutoXenon, I will try again. This has nothing at all to do with "seven positional arguments" - whether zero-counted or not. As it stands there is absolutely no point in running your posted code snippet as it is blatantly incorrect to even the most cursory glance. You are applying the extended style you need to apply to the GUI to the control itself. The example to which you were twice referred makes it quite clear that both the GUI and the control need specific actions; an extended style applied to the GUI, and a specific state set for the control. When this is done, the drag'n'drop works correctly. M23 Skysnake 1 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...
AutoBert Posted January 17, 2023 Share Posted January 17, 2023 Here's a small script to demonstrate droping to LV (can be easy changed to other controls): expandcollapse popup#include <File.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> ;#include <Array.au3> ;only for info's Opt('GUIOnEventMode',1) Global $hGui = GUICreate('DropTest', 400, 400, @DesktopWidth -404, -1, -1,$WS_EX_ACCEPTFILES) Global $idLV = GUICtrlCreateListView('Name: |Ext |Path',0,0,400,400) GUICtrlSetState(-1 ,$GUI_DROPACCEPTED) GUISetOnEvent($GUI_EVENT_CLOSE,Quit) GUISetOnEvent($GUI_EVENT_DROPPED, Drop) GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES_FUNC") GUISetState() Global $aDropFiles[1] While Sleep(1000) WEnd Func Quit() Exit EndFunc Func Drop() Local $szDrive, $szDir, $szFName, $szExt, $split ;_ArrayDisplay($aDropFiles) _GUICtrlListView_BeginUpdate($idLV) For $i = 0 To UBound($aDropFiles) - 1 $split = _PathSplit($aDropFiles[$i], $szDrive, $szDir, $szFName, $szExt) $szExt = StringUpper($szExt) Switch $szExt Case ".TXT", ".INI", ".AU3", ".PDF" GUICtrlCreateListViewItem($szFName & "|" & StringTrimLeft($szExt, 1) & "|" & $aDropFiles[$i], $idLV) EndSwitch Next _GUICtrlListView_SetColumnWidth($idLV, 0, $LVSCW_AUTOSIZE) _GUICtrlListView_EndUpdate($idLV) MsgBox(0,'','droped') EndFunc 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 $aDropFiles[$i + 1] $aDropFiles[$i] = DllStructGetData($pFileName, 1) $pFileName = 0 Next EndFunc ;==>WM_DROPFILES_FUNC 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