Massi Posted September 23, 2014 Share Posted September 23, 2014 (edited) Hi all. I have a problem with Listview function.I recently update from Autoit version 3.3.8.1 to new one. After the update the functions _GUICtrlListView_BeginUpdate - _GUICtrlListView_EndUpdate doesn't work in the right way. Listview doesn't wait _GUICtrlListView_EndUpdate to start updating so all the process is very slow.I try to search what's wrong but I can't manage to make it work.This is a piece of the code working, just to re-create the problemexpandcollapse popup#include-once #include <EditConstants.au3> #include <Array.au3> #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> Local $nMeta=550,$nAltezzaRiga=30,$nHMeta=300,$nLarghezzaLabel=70 ;PRIMA ERA 270 $Hmeta=$AltezzaRiga*9 Local $LarghezzaFinestra=1100,$AltezzaFinestra=700,$Font="Arial" $hFinestra = GUICreate("TEST", $LarghezzaFinestra,$AltezzaFinestra) ; Crea una finestra larga 800 e alta 600 GUISetState(@SW_SHOW,$hFinestra) GUISetFont(10, 400, 0, "Comic Sans MS") $lv = GUICtrlCreateListView("", 2, 2, $LarghezzaFinestra-4, 356);,$LVS_SORTDESCENDING) $hLV = GUICtrlGetHandle($lv) _GUICtrlListView_SetExtendedListViewStyle($hLV, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) _GUICtrlListView_AddColumn($hLV, "", 1500) $BottoneRicerca = GUICtrlCreateButton("TEST", 250 ,380+ $nAltezzaRiga*5-3, 55, 30);30+$nLarghezzaLabel+220 + 400 local $aRisultatoTotale[100][50] For $x=0 To 99 for $y=0 To 49 $aRisultatoTotale[$x][$y]="AAAAAAAAAAAA" Next Next Local $aNomeTabellaDatabase[3]=["2","TEST1","TEST2"] Local $aNumeroColonneTabella[3]=["2","10","15"] Local $aNumeroRigheTabella[3]=["2","3","6"] While 1 $msg=GUIGetMsg() Select Case $msg=$BottoneRicerca GuiRicerca($hFinestra,$lv,$hLV,$aRisultatoTotale, $aNomeTabellaDatabase, $aNumeroColonneTabella, $aNumeroRigheTabella) Case $msg=$GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete($hFinestra) Func GuiRicerca($hFinestra,$lv,$hLV,$aRisultatoTotale, ByRef $aNomeTabellaDatabase, ByRef $aNumeroColonneTabella, ByRef $aNumeroRigheTabella) Local $LarghezzaFinestra=1100,$AltezzaFinestra=700,$Font="Arial" Local $hDC = _WinAPI_GetDC($hLV) Local $hFont = _SendMessage($hLV, $WM_GETFONT) Local $hObject = _WinAPI_SelectObject($hDC, $hFont) Local $lvLOGFONT = DllStructCreate($tagLOGFONT) Local $aRet = DllCall('gdi32.dll', 'int', 'GetObjectW', 'ptr', $hFont, 'int', DllStructGetSize($lvLOGFONT), 'ptr', DllStructGetPtr($lvLOGFONT)) _WinAPI_SelectObject($hDC, $hObject) _WinAPI_ReleaseDC($hLV, $hDC) DllStructSetData( $lvLOGFONT, "Height",15) $hLVfont = _WinAPI_CreateFontIndirect( $lvLOGFONT ) DllStructSetData( $lvLOGFONT, "Weight", 700 ) $hLVfontBold = _WinAPI_CreateFontIndirect( $lvLOGFONT ) DllStructSetData( $lvLOGFONT, "Italic", True ) ;0 for normal, 1 for italic $hLVfontBoldItalic = _WinAPI_CreateFontIndirect( $lvLOGFONT ) DllStructSetData( $lvLOGFONT, "Weight", 400 ) ;700 for bold, 400 for regular $hLVfontItalic = _WinAPI_CreateFontIndirect( $lvLOGFONT ) _GUICtrlListView_BeginUpdate($hLV) ; *************************************BEGIN of LISTVIEW UPDATE While _GUICtrlListView_DeleteColumn($hLV, 1)=True ;Delete all the columns WEnd _GUICtrlListView_DeleteAllItems($hLV) ; Delete all item from ListView For $x=1 to UBound($aRisultatoTotale,2)-1 ; Add columns (in this example the number of columns doesn't change) _GUICtrlListView_AddColumn($hLV, "", 100) Next $stringa="" For $x=0 To UBound($aRisultatoTotale,1)-1 _GUICtrlListView_AddItem( $hLV,$aRisultatoTotale[$x][0]) For $y=1 to UBound($aRisultatoTotale,2)-1 _GUICtrlListView_AddSubItem( $hLV,$x,$aRisultatoTotale[$x][$y],$y) Next Next For $x=0 to UBound($aRisultatoTotale,2)-1 _GUICtrlListView_SetColumnWidth($lv, $x, $LVSCW_AUTOSIZE) ; Autofit the columns Next _GUICtrlListView_EndUpdate($hLV) ; *************************************END of LISTVIEW UPDATE EndFunc Edited September 23, 2014 by Melba23 Amended thread title Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 23, 2014 Moderators Share Posted September 23, 2014 Massi,When I run your code in both 3.3.12.0 and 3.3.13.19 the ListView update occurs only when the _GUICtrlListView_EndUpdate function is called and is extremely fast. Commenting the _GUICtrlListView_Start/EndUpdate lines results in the very slow update that would be expected. So I do not believe the problem is AutoIt-based - I have amended the thread title accordingly. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Massi Posted September 23, 2014 Author Share Posted September 23, 2014 Sorry Melba, yes I see the function _GUICtrlListView_EndUpdate is fast but here listview begins updating before _GUICtrlListView_EndUpdate function is called. The first time you push TEST all works well. Please, try to push the test button more than once. If you see autofit columns start before _GUICtrlListView_EndUpdate(maibe is diffcult to see because all the word are equal "AAAA"). If you put _GUICtrlListView_AddColumn($hLV, "", 50) instead of 100 this result is more clear As I said in version 3.3.8.1 this doesn't happen but maybe is a script problem or a PC problem, in this case please accept my apologies Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 23, 2014 Moderators Share Posted September 23, 2014 Massi,I see what you mean - the second time you do get the slow update. I believe this is because you are deleting all the columns and then adding new ones without allowing the control to realise what is happening. If I give the ListView a chance to update between these two sections it no longer shows the slow update:_GUICtrlListView_BeginUpdate($hLV) ; ***********************************BEGIN of LISTVIEW UPDATE While _GUICtrlListView_DeleteColumn($hLV, 1) = True WEnd _GUICtrlListView_DeleteAllItems($hLV) ; Delete all item from ListView _GUICtrlListView_EndUpdate($hLV) ; *************************************END of LISTVIEW UPDATE ; Allow the ListView to update _GUICtrlListView_BeginUpdate($hLV) ; ***********************************BEGIN of LISTVIEW UPDATE ; Updating code _GUICtrlListView_EndUpdate($hLV) ; *************************************END of LISTVIEW UPDATEDoes that work for you? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Massi Posted September 23, 2014 Author Share Posted September 23, 2014 (edited) Melba, N1I also try to put other _GUICtrlListView_BeginUpdate($hLV) and _GUICtrlListView_EndUpdate($hLV) in other points of the script for debugging and was not working,I see that the GuiListView.au3 is changed in the two versions but was very complicated to understand the differences.I think that the right way to work was the previous one or the function doesn't do "Prevents updating of the control until the _GUICtrlListView_EndUpdate() function is called".Make a lot of operations in listview should not modify the behaviour of the function.This behaviour have to be documented or in my opinion this is a little bug.In everycase this workaround work for me, thank you Melba Edited September 23, 2014 by Melba23 Resized font Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted September 23, 2014 Moderators Solution Share Posted September 23, 2014 (edited) Massi,I have just checked the _GUIListView libraries in 3.3.8.1 and 3.3.12.0 and I have found the reason you see this change in behaviour. The _GUICtrlListView_DeleteAllItems in v3.3.8.1 did not actually work, so I rewrote it. If the ListView is created by the native GUICtrlCreateListView function deleting all the items takes some time, so I added an internal version of the Begin/EndUpdate function. Thus in your script, calling that function means that the ListView is updated as it exits and so you need to reset the StartUpdate state before you start refilling. I will add a remark to the _GUICtrlListView_DeleteAllItems page in the Help file explaining this - thanks for noticing it! M23Edit: Remark added. Edited September 23, 2014 by Melba23 MikahS 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Massi Posted September 23, 2014 Author Share Posted September 23, 2014 Thank you Melba, now is all clear and working. If I put _GUICtrlListView_BeginUpdate after _GUICtrlListView_DeleteAllItems all work fine(there is no need of _GUICtrlListView_EndUpdate because the function already do this). Is exactly as you say (I try other scripts with _GUICtrlListView_BeginUpdate but I cannot replicate the problem because it was in another function ) Thank you very much for helping me Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 23, 2014 Moderators Share Posted September 23, 2014 Massi,My pleasure (particularly as it was my fault!). M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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