Achilles Posted October 20, 2009 Share Posted October 20, 2009 (edited) Is there a way to reset the return value of _GUICtrlListView_MapIndextoId... I have a listview where the items are constantly being cleared and put on again.. this results in large ID numbers.. where, since the list is being cleared, starting at 0 again would be preferred. Here's an example, just hit reset a couple times. expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <Array.au3> GUICreate("ListView Map ID To Index", 400, 400) $hListView = GUICtrlCreateListView("", 2, 2, 394, 268) GUISetState() $btn = GUICtrlCreateButton('Reset', 10, 350, 200, 25) ; Add column _GUICtrlListView_AddColumn($hListView, "Items", 400) ; Add items Global $itemArray[1] For $i = 1 to 25 $temp = _GUICtrlListView_AddItem($hListView, "Item " & $i) _ArrayAdd($itemArray, $temp) Next _ArrayDisplay($itemArray, 'Mapped IDs') ; Loop until user exits While 1 Switch GUIGetMsg() Case $btn ; Clear all _GUICtrlLIstView_DeleteAllItems($hListView) ReDIm $itemArray[1] $itemArray[0] = '' ;Add new items, map them too For $i = 1 to 25 $temp = _GUICtrlListView_AddItem($hListView, "Item " & $i) _ArrayAdd($itemArray, $temp) Next _ArrayDisplay($itemArray, 'Mapped IDs') Case $GUI_EVENT_CLOSE Exit EndSwitch WEND Edited October 20, 2009 by Achilles My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Authenticity Posted October 20, 2009 Share Posted October 20, 2009 Look how the _GUICtrlListView_DeleteAllItems() function is defined. If you send it something other than a handle to a listview control, it'll just use GUICtrlDelete(). Otherwise it'll send the LVM_DELETEALLITEMS, which resets the value of the index and items count. $hListView = GUICtrlGetHandle($hListView) Link to comment Share on other sites More sharing options...
wraithdu Posted October 20, 2009 Share Posted October 20, 2009 (edited) It's also increasing the ID because you are not actually deleting any listview items. Watch your example, the list grows each time you reset it. As Authenticity pointed out, using GUICtrlDelete() on a control that is not managed by AutoIt (such as those created with _GUICtrlListView_AddItem()) will fail. Just change this line: _GUICtrlLIstView_DeleteAllItems(GUICtrlGetHandle($hListView)) Edited October 20, 2009 by wraithdu 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