how to limit dragging area ?
#1
Posted 28 April 2012 - 03:28 PM
#2
Posted 29 April 2012 - 12:25 AM
The following built-in variables are available within GuiDropFiles:
1. A_GuiControl, which contains the text or variable name of the control upon which
the files were dropped (blank if none).
2. A_EventInfo and ErrorLevel, which both contain the number of files dropped.
3. A_GuiX and A_GuiY, which contain the X and Y coordinates of where the files were
dropped (relative to the window's upper left corner).
4. A_GuiEvent, which contains the names of the files that were dropped, with each
filename except the last terminated by a linefeed (`n).
GuiDropFiles: if A_GuiControl in Button1, Button2, Button3 return ; ignore the drop ;-- else accept the files ---- return
#3
Posted 29 April 2012 - 05:45 PM
#4
Posted 29 April 2012 - 11:33 PM
I do not have an example other than the partial idea I posted.I did not work that " if "... sorry, do you have an example ?
I asked a question and you did not respond to it.
Please explain what you want in more detail.
Please post an example script and tell us what you want.
#5
Posted 30 April 2012 - 12:26 AM
I want only listboxes accept dropping a file ? Not Background or other controls ...
Gui, Add, ListBox, x15 y10 w195 h230, ListBox Gui, Add, ListBox, x220 y10 w195 h225, ListBox2 Gui, Add, Edit, x20 y260 w190 h20, Edit Gui, Add, Button, x315 y260 w100 h30, Button Gui, Show, w430 h302, Gui Return GuiClose: ExitApp
#6
Posted 30 April 2012 - 02:08 AM
Gui, Add, ListBox, x15 y10 w195 h230 vListBox, Red|Green|Blue|Black|White
Gui, Add, ListBox, x220 y10 w195 h225 vListBox2 Red|Green|Blue|Black|White
Gui, Add, Edit, x20 y260 w190 h20, Edit
Gui, Add, Button, x315 y260 w100 h30, Button
Gui, Show, w430 h302, Gui
Return
GuiClose:
ExitApp
GuiDropFiles:
if A_GuiControl not contains Listbox
{
tooltip, Sorry`, Klark92 says you must drop files in Listboxes `r%A_GuiControl% doesn't qualify
return ; ignore the drop
}
;-- else accept the files ----
msgbox You dropped files on %A_GuiControl%`rThere were %A_EventInfo% files`rThe location was %A_GuiX%`,%A_GuiY%`rThe list of files is %A_GuiEvent%
return
#7
Posted 30 April 2012 - 06:04 AM
; Should work with AHK Basic, too!
#NoEnv
; WS_EX_ACCEPTFILES := 0x00000010
Gui, Add, ListBox, x15 y10 w195 h230 +E0x10 HwndHLB1 vListBox1, ListBox
Gui, Add, ListBox, x220 y10 w195 h225 +E0x10 HwndHLB2 vListBox2, ListBox2
Gui, Add, Edit, x20 y260 w190 h20, Edit
Gui, Add, Button, x315 y260 w100 h30, Button
Gui, Show, w430 h302, Gui
GoSub, NoDropOnGUI
Return
GuiClose:
ExitApp
GuiDropFiles:
; We cannot rely on A_GuiControl in this context (AHK 1.1.07.03 U32).
; So we have to get the control using MouseGetPos
MouseGetPos, , , , HDROP, 2
If (HDROP = HLB1)
DropTarget := "ListBox1"
Else ; because there are only two controls
DropTarget := "ListBox2"
MsgBox, 0, Dropped!, You dropped`r`n`r`n%A_GuiEvent%`r`n`r`non %DropTarget%!`r`n`r`nA_GuiControl: %A_GuiControl%
SetTimer, NoDropOnGUI, -100 ; Seems to be needed after dropping
Return
NoDropOnGUI:
Gui, +LastFound
Gui, -E0x10
WinActivate
ReturnA little closer?
#8
Posted 30 April 2012 - 06:21 AM
GuiDropFiles: ; We cannot rely on A_GuiControl in this context (AHK 1.1.07.03 U32). ; So we have to get the control using MouseGetPos
Can you elaborate on this statement ?
#9
Posted 30 April 2012 - 08:47 AM
Finally it works. Thanks a lot leef_me !
#10
Posted 30 April 2012 - 08:48 AM
A_GuiControl does always contain the name of the first input-capable control in this case. I don't know whether this issue relies on my AHK version, or not.
#11
Posted 30 April 2012 - 09:08 AM
#12
Posted 30 April 2012 - 11:29 AM
#13
Posted 30 April 2012 - 04:10 PM
#14
Posted 30 April 2012 - 04:28 PM
Your statement seems contrary to the information published in the docs.It works for more than one control, you just can't use A_GuiControl.
<!-- m -->http://l.autohotkey.... ... iDropFiles<!-- m -->
:?: Can you provide an example that supports your statement ?
#15
Posted 30 April 2012 - 07:56 PM
A_GuiControl reported in the MessageBox. And observe that WS_EX_ACCEPTFILES is removed from the Gui window, that's the whole trick!




