JamesPy Posted September 24, 2015 Posted September 24, 2015 (edited) I have a simple GUI with two file selection fields. The user can drag a file into Field A, and can drag a file into Field B. Both fields have "C:\" in them to begin with...Dragging the file to Field A works fine. The pathway and file are displayed correctly.However Once this is done, when you drag a file into Field B, the path and name are displayed, but are appended with C:\I realised that the reason being is that when you drag the first file, the focus is on Field A, and the C:\ that is already in the field becomes highlighted as you move the mouse over the GUI.For Field B, the focus is still on Field A, so it doesn't overwrite the c:\, but appends it to the file name. Here is my code (simplified):#include <GuiConstants.au3> #include <GuiConstantsEx.au3> #include <FileConstants.au3> #include <EditConstants.au3> GuiCreate('Test App', 700, 600, @DesktopWidth / 2 - 192, _ @DesktopHeight / 2 - 235, -1, $WS_EX_ACCEPTFILES) GUICtrlCreateGroup("Dict Files", 5, 5, 570, 90) GUICtrlCreateLabel('Select file:', 20, 30) $dropmpfile = GUICtrlCreateInput ("C:\", 120, 30, 200, 20, -1, $WS_EX_STATICEDGE) GUICtrlSetState (-1, $GUI_DROPACCEPTED) GUICtrlSetTip (-1, 'You can drag & drop files here...') GUICtrlCreateLabel('Select file:', 20, 60) $droporgfile = GUICtrlCreateInput ("C:\", 120, 60, 200, 20, -1, $WS_EX_STATICEDGE) GUICtrlSetState (-1, $GUI_DROPACCEPTED) GUICtrlSetTip (-1, 'You can drag & drop files here...') ;GUI MESSAGE LOOP GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEndIf somebody could help me resolve this I would be really, REALLY grateful!! Thanks in advance - James Edited September 24, 2015 by Melba23 Added code tags
mikell Posted September 24, 2015 Posted September 24, 2015 Just add this in the main loopCase $msg = $GUI_EVENT_DROPPED GuiCtrlSetData(@GUI_DropId, @GUI_DragFile)Please use the code tag <> when you post code
kylomas Posted October 3, 2015 Posted October 3, 2015 JamesPy,What is the point of priming the input control? The full file path will be dropped. The following accomplishes the same thing as processing the drop event...#include <GuiConstants.au3> #include <GuiConstantsEx.au3> #include <FileConstants.au3> #include <EditConstants.au3> GuiCreate('Test App', 700, 600, @DesktopWidth / 2 - 192, _ @DesktopHeight / 2 - 235, -1, $WS_EX_ACCEPTFILES) GUICtrlCreateGroup("Dict Files", 5, 5, 570, 90) GUICtrlCreateLabel('Select file:', 20, 30) $dropmpfile = GUICtrlCreateInput ("", 120, 30, 200, 20, -1, $WS_EX_STATICEDGE) GUICtrlSetState (-1, $GUI_DROPACCEPTED) GUICtrlSetTip (-1, 'You can drag & drop files here...') GUICtrlCreateLabel('Select file:', 20, 60) $droporgfile = GUICtrlCreateInput ("", 120, 60, 200, 20, -1, $WS_EX_STATICEDGE) GUICtrlSetState (-1, $GUI_DROPACCEPTED) GUICtrlSetTip (-1, 'You can drag & drop files here...') ;GUI MESSAGE LOOP GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEndkylomas 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
mikell Posted October 3, 2015 Posted October 3, 2015 The OP vanished in the haze like an autumn leaf in the november wind ...
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