Montfrooij Posted October 25, 2010 Share Posted October 25, 2010 (edited) Hello, I've got a problem with repopulating listviews. The initial population is done without delay, but the repopulating takes a moment. I've added a simplified script that shows what I mean:Click 'Start' and you will see the GUI with the listview being generated (fast),Click 'Repopulate' and you will see the listview being repopulated (slower).Both populations of the listview are done the same way (as far as I can tell) How can I make the repopulate action faster?Thanks in advance. expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <WindowsConstants.au3> Global $hListView, $hListView2,$bRepop,$bStart GUICreate("Start", 300, 50) $bStart = GUICtrlCreateButton("Start", 10, 10, 280, 25) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $bStart _Example1() EndSwitch WEnd Func _Example1() ;GUI with listview Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE) Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER) GUICreate("ListView Sort", 300, 300) $bRepop = GUICtrlCreateButton("Repopulate", 10, 270, 280, 25) $hListView = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 260, -1, $iExWindowStyle) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) _GUICtrlListView_SetExtendedListViewStyle($hListView, $iExListViewStyle) For $r = 1 To 1000 GUICtrlCreateListViewItem($r & "|" & random(0,90) &"|" & random(0,90),$hListView) GUICtrlSetBkColor(-1, 0xD0DEC7) Next MsgBox(0,"","Ready") GUISetState() _GUICtrlListView_RegisterSortCallBack($hListView) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hListView ; Kick off the sort callback _GUICtrlListView_SortItems($hListView, GUICtrlGetState($hListView)) Case $bRepop _Repop() EndSwitch WEnd _GUICtrlListView_UnRegisterSortCallBack($hListView) GUIDelete() EndFunc ;==>_Example1 Func _Repop() _GUICtrlListView_DeleteAllItems($hListView) For $r = 1 To 1000 GUICtrlCreateListViewItem($r & "|" & random(0,90) &"|" & random(0,90),$hListView) GUICtrlSetBkColor(-1, 0xD0DEC7) Next MsgBox(0,"","Ready") EndFunc Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iCode, $tNMHDR, $hWndListView, $hWndListView2 $hWndListView = $hListView $hWndListView2 = $hListView2 If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) If Not IsHWnd($hListView2) Then $hWndListView2 = GUICtrlGetHandle($hListView2) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView, $hWndListView2 Switch $iCode Case $LVN_COLUMNCLICK ; A column was clicked Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) ; Kick off the sort callback _GUICtrlListView_SortItems($hWndFrom, DllStructGetData($tInfo, "SubItem")) ; No return value EndSwitch EndSwitch Return $__LISTVIEWCONSTANT_GUI_RUNDEFMSG EndFunc ;==>_WM_NOTIFY Edited November 29, 2010 by Montfrooij Link to comment Share on other sites More sharing options...
Yashied Posted October 25, 2010 Share Posted October 25, 2010 ... Dim $aItem[1000] ... Func _Example1() ... For $r = 1 To 1000 $aItem[$r - 1] = GUICtrlCreateListViewItem($r & "|" & Random(0, 90) & "|" & Random(0, 90), $hListView) GUICtrlSetBkColor(-1, 0xD0DEC7) Next MsgBox(0, "", "Ready") ... EndFunc ;==>_Example1 Func _Repop() For $r = 1 To 1000 GUICtrlSetData($aItem[$r - 1], $r & "|" & Random(0, 90) & "|" & Random(0, 90)) Next MsgBox(0, "", "Ready") EndFunc ;==>_Repop ... My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Montfrooij Posted October 25, 2010 Author Share Posted October 25, 2010 That seems to work like a charm. I will try and implement this in the 'real' code. Thanks a lot. 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