Jump to content

Recommended Posts

Posted (edited)

Hi,

at work we changed now from windows 7 to windows 10. Suddenly this command _GUICtrlListView_GetHotItem() isn't working anymore for me. When I drag&drop a listviewitem it always returns -1.

Here is the script that worked with WIN7:

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <Misc.au3>

Local $aArray_Base[5][2] = [["0 - 0", "0 - 1"], ["1 - 0", "1 - 1"], ["2 - 0", "2 - 1"], ["3 - 0", "3 - 1"], ["4 - 0", "4 - 1"]]
GUICreate("listview", 220, 200)
Global $g_idListView = GUICtrlCreateListView("", 10, 10, 200, 180)
_GUICtrlListView_AddColumn($g_idListView, "Col 1", 100)
_GUICtrlListView_AddColumn($g_idListView, "Col 2", 100)
_GUICtrlListView_AddArray($g_idListView, $aArray_Base)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $GUI_EVENT_PRIMARYDOWN
            _Arrange_List()
    EndSwitch
WEnd

Func _Arrange_List()
    Local $iSelected = _GUICtrlListView_GetSelectionMark($g_idListView)
    If $iSelected = -1 Then Return
    While _IsPressed(1)
    WEnd
    Local $iDropped = _GUICtrlListView_GetHotItem($g_idListView)
    ConsoleWrite("GetHotItem: " & $iDropped & @CRLF)

    If $iDropped > -1 Then
        _GUICtrlListView_BeginUpdate($g_idListView)
        If $iSelected < $iDropped Then
            _GUICtrlListView_InsertItem($g_idListView, "", $iDropped + 1)
            _GUICtrlListView_SetItemText($g_idListView, $iDropped +1, _GUICtrlListView_GetItemTextString($g_idListView, $iSelected), -1)
            _GUICtrlListView_DeleteItem($g_idListView, $iSelected)
        ElseIf $iSelected > $iDropped Then
            _GUICtrlListView_InsertItem($g_idListView, "", $iDropped)
            _GUICtrlListView_SetItemText($g_idListView, $iDropped, _GUICtrlListView_GetItemTextString($g_idListView, $iSelected + 1), -1)
            _GUICtrlListView_DeleteItem($g_idListView, $iSelected + 1)
        EndIf
        _GUICtrlListView_SetItemSelected($g_idListView, $iDropped)
        _GUICtrlListView_SetSelectionMark($g_idListView, $iDropped)
        _GUICtrlListView_EndUpdate($g_idListView)
    EndIf
EndFunc

Any ideas?

Regards, Simpel

 

P.S. If I click an item then $iDropped is returning the correct number.

Edited by Simpel
add P.S.
SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Posted

The code above returns -1 on both Windows 10 and 7, I would recommend you look at Melba23 GUIListViewEx UDF, it is able to track drag and drop and alot more.

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...