photonbuddy Posted February 29, 2008 Share Posted February 29, 2008 Hi All, I'm sure there's a simple answer to this using BitAnd or BitOr, but I can't seem to find it. I have created a listview, and added listview items to it. This works, and the first entry returns an index of 4108 when using GUICtrlRead. The problem I am having is that after the initial set-up of the listview, if I add another item, the index number jumps by more than 1 when I use GUICtrlRead to get the index number. Any ideas on how to fix this? The listview is created without any styles or exstyles, as are the listviewitems. Link to comment Share on other sites More sharing options...
rasim Posted February 29, 2008 Share Posted February 29, 2008 (edited) Hi! Example: expandcollapse popup#include <GuiListView.au3> #include <GuiConstantsEx.au3> $Gui = GUICreate("Test", 300, 200) $hListView = _GUICtrlListView_Create($GUI, "Items|SubItems", 20, 15, 260, 150, BitOR($LVS_EDITLABELS, $LVS_REPORT), $WS_EX_CLIENTEDGE) _GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_SUBITEMIMAGES) _GUICtrlListView_AddItem($hListView, "Item1") _GUICtrlListView_AddItem($hListView, "Item2") _GUICtrlListView_AddItem($hListView, "Item3") _GUICtrlListView_AddItem($hListView, "Item4") $AddButton = GUICtrlCreateButton("Add", 20, 172, 50, 20) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $AddButton _InsertItem() EndSwitch WEnd Func _InsertItem() Local $iIndex = _GUICtrlListView_GetItemCount($hListView) _GUICtrlListView_InsertItem($hListView, "Item" & $iIndex + 1) EndFunc ;==>_InsertItem Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_INSERTITEM Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) Local $iIndex = DllStructGetData($tInfo, "Item") ConsoleWrite("Added new item with index #" & $iIndex & @LF) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Edited February 29, 2008 by rasim 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