abberration Posted June 25, 2020 Share Posted June 25, 2020 (edited) Hello, everyone - I hope everyone is doing well... I am working on a project where it will accept drag & drop files (an mp3 encoder). Working great so far. However, I notice when you drag a file over the GUI, it has a plus symbol indicating you are able to drop it anywhere over the GUI. I would like that plus symbol to only appear over the intended input box. I think it's confusing to think you can drag & drop a file anywhere, but actually only be able to over the specified item. Can this be accomplished? I haven't found any threads on this particular subject. Thanks for any ideas! Whittled down example code: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> $Form2 = GUICreate("Form2", 565, 247, -1, -1, -1, BitOR($WS_EX_ACCEPTFILES,$WS_EX_WINDOWEDGE)) $Input1 = GUICtrlCreateInput("", 32, 16, 505, 21) ; <-- This is the only place I want the drop indicator to appear. GUICtrlSetState(-1, $GUI_DROPACCEPTED) $Tab1 = GUICtrlCreateTab(32, 48, 505, 185) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Input1 $gRead = GUICtrlRead($Input1) GUICtrlSetData($Input1, $gRead) EndSwitch WEnd Edited June 25, 2020 by abberration Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
Nine Posted June 25, 2020 Share Posted June 25, 2020 Try this : #include <GUIConstants.au3> $Form2 = GUICreate("Form2", 565, 247, -1, -1, -1, $WS_EX_WINDOWEDGE) $Input1 = GUICtrlCreateInput("", 32, 16, 505, 21, -1, $WS_EX_ACCEPTFILES) ; Now only here the drop sign appears GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED ; Not triggered, I think it should be considered as a bug ConsoleWrite (@GUI_DragFile & @CRLF) Case $Input1 ConsoleWrite ("input1" & @CRLF) EndSwitch WEnd But no msg is triggered. I would tend to consider it as a bug. There must be a more complex solution that I cannot think at the moment. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Nine Posted June 25, 2020 Share Posted June 25, 2020 (edited) Found a way, still I tend to believe it might be a bug. But anyway, I have found a way not too complicated : expandcollapse popup#include <GUIConstants.au3> #include <WinAPI.au3> #include <Array.au3> Global $aFileList $hGUI = GUICreate("Form2", 565, 247, -1, -1, -1, $WS_EX_WINDOWEDGE) $Input1 = GUICtrlCreateInput("", 32, 16, 505, 121, -1, $WS_EX_ACCEPTFILES) ; Now only here the drop sign appears GUICtrlSetState(-1, $GUI_DROPACCEPTED) Global $idDummy = GUICtrlCreateDummy() GUISetState() $wProcHandle = DllCallbackRegister("_WindowProc", "ptr", "hwnd;uint;wparam;lparam") $wProcOld = _WinAPI_SetWindowLong(GUICtrlGetHandle($Input1), $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle)) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED ; Not triggered, I think it should be considered as a bug ConsoleWrite(@GUI_DragFile & @CRLF) Case $Input1 ConsoleWrite("input1" & @CRLF) Case $idDummy For $i = 1 To $aFileList[0] ConsoleWrite($aFileList[$i] & @CRLF) Next GUICtrlSetData ($Input1, _ArrayToString ($aFileList,"|",1)) EndSwitch WEnd GUIDelete($hGUI) DllCallbackFree($wProcHandle) Func _WindowProc($hWnd, $Msg, $wParam, $lParam) Switch $hWnd Case GUICtrlGetHandle($Input1) Switch $Msg Case $WM_DROPFILES $aFileList = _WinAPI_DragQueryFileEx($wParam) If Not @error Then GUICtrlSendToDummy($idDummy) _WinAPI_DragFinish($wParam) Return 0 EndSwitch EndSwitch Return _WinAPI_CallWindowProc($wProcOld, $hWnd, $Msg, $wParam, $lParam) EndFunc ;==>_WindowProc Needs some cleanup but you will get the idea... Edited June 25, 2020 by Nine abberration 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
abberration Posted June 26, 2020 Author Share Posted June 26, 2020 Hello Nine, Thank you for your response. That is impressive. I'm not as advanced as you, so I will have to work on understanding your code. Cheers! Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
Nine Posted June 26, 2020 Share Posted June 26, 2020 @abberration FYI - Just talked to the devs, and they say it is not a bug, it is the way they implemented it. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
abberration Posted June 26, 2020 Author Share Posted June 26, 2020 Good to know. I thought I was just getting the BitOr options wrong. Thanks again for your help! Easy MP3 | Software Installer | Password Manager 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