ListView Drag and Drop

Propose new features and changes
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

ListView Drag and Drop

19 Jul 2017, 03:37

Request for v2 (maybe v1.1 too)

From ahk:

Code: Select all

https://autohotkey.com/docs/commands/ListView.htm#notify
D: The user has attempted to start dragging a row or icon (there is currently no built-in support for dragging rows or icons). The variable A_EventInfo contains the focused row number. In v1.0.44+, this notification occurs even without AltSubmit.
From au3:

Code: Select all

https://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetState.htm
$GUI_DROPACCEPTED (8)    -    Control will accept drop action : from file or from a drag of another control. See remarks.

If $GUI_DROPACCEPTED (8) is set to a visible control a drag & drop can be taken in account. The edit/input control will be set with the filename.
For other controls on reception of $GUI_EVENT_DROPPED, @GUI_DragId will return the controlID from where the drag start (-1 if from a file, @GUI_DragFile contain the filename being dropped) and @GUI_DropId returns the controlID of the dropped control.
Only dragging a ListviewItem will start the drag & drop process. The @GUI_DragId will be the ListView controlID.
e.g.

Code: Select all

Dim $LISTVIEW_ITEM[10]

$GUI = GUICreate("Drag'n'Drop",800,600,-1,-1)
$LISTVIEW_LEFT = GUICtrlCreateListView("Column 1|Column 2|Column 3|Column 4",0,0,400,600)
GUICtrlSetState(-1, 8) ; $GUI_DROPACCEPTED = 8

For $i = 0 To 9
    $LISTVIEW_ITEM[$i] = GUICtrlCreateListViewItem("Item "&$i,$LISTVIEW_LEFT)
Next

$LISTVIEW_RIGHT = GUICtrlCreateListView("Column 1|Column 2|Column 3|Column 4",400,0,400,600)
GUICtrlSetState(-1, 8) ; $GUI_DROPACCEPTED = 8

GUISetState(@SW_SHOW)

While True
    Switch GUIGetMsg()
        Case -3
            ExitLoop
        Case -13
            MoveItem(@GUI_DragId, @GUI_DropId)
    EndSwitch
WEnd

Func MoveItem($drag, $drop)
    GUICtrlCreateListViewItem(GUICtrlRead(GUICtrlRead($drag)), $drop)
    GUICtrlDelete(GUICtrlRead($drag))
EndFunc
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: ListView Drag and Drop

14 Aug 2017, 20:05

Agreed!
User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: ListView Drag and Drop

16 Aug 2017, 07:11

Seems about right, the problem is trying to find a way to keep what the icon or column or even row to a variable to use. I would guess it would be A_EventInfo but there could be a lot more added to it.

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat


Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 22 guests