Sign in to follow this  
Followers 0
EKY32

~ Loading many items to ListView makes the window flashs! (Solved)

12 posts in this topic

#1 ·  Posted (edited)

I have a GuiCtrlCreateListView, and a database with a huge quantity of rows, the scripts loads the data from the database to the list view (GuiCtrlCreateListViewItem), so it makes the window flashes and very slow, so I used _GUICtrlListView_BeginUpdate and _GUICtrlListView_EndUpdate it helped a bit, but the window still flashes as i need to recall the listing func each minute.

Is there any way to fix that please?

Thank you.

Edited by EKY32

[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

Share this post


Link to post
Share on other sites



EKY32,

In short, no! :)

The only way I have found to stop the filckering is to hide the ListView at the beginning of the update and then show it again once the reload is completed. ;)

Why are you recall the listing function so often? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Try: disable the control, update the listview elements and finally enable the control again.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I don't seem to have any problems with flashing using the following code. The first time you click click the list view population is slow. On subsequent clicks it is much faster. This makes me wonder if creating empty rows first might be faster (I don't know).

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <String.au3>

_Run()

Func _Run()
    Local $dStyle = BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)
    Local $dTestGUI = GUICreate(" ListView Test", 300, 200, Default, Default, $dStyle)

    Local $sHeadings = "Click" & _StringRepeat("| ", 4)
    Local $hListView = GUICtrlCreateListView($sHeadings, 0, 0, 300, 200, BitOR($LVS_REPORT,$LVS_SHOWSELALWAYS))
    _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
    ;GUICtrlSetBkColor($hListView, 0xFFFFFF)

    GUISetState(@SW_SHOW)

    ;================================================================================
    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $msg = $hListView Then _Populate($hListView)
    WEnd
    ;===============================================================================
EndFunc

Func _Populate($hListView)
    Local $iCols = 5

    Local $hControlHandle = GUICtrlGetHandle($hListView)
    _GUICtrlListView_DeleteAllItems($hControlHandle)

    Local $sData
    For $i = 1 To 10000
        $sData = $i
        For $j = 0 To $iCols -1
            $sData &= "|"
            $sData &= $i & "," & $j
        Next
        GUICtrlCreateListViewItem($sData, $hListView)
    Next
    _GUICtrlListView_SetColumn($hListView, 0, "Click")
EndFunc
Edited by czardas

Share this post


Link to post
Share on other sites

Well, this script looks good, i'll find a way to combine it with mine.

Mr.Melba23, I have a compo box as a filter for the list view items, so when i choose a string from it, it must delete all the items of the list and get them again filtered from the database.. is it really that bad? i must disable or hide the list view? :(

I'll try the script czardas gave me, then get back again, thank you.


[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

Share this post


Link to post
Share on other sites

Sorry, neither disabling nor hiding the listview stopped flickering the window, any other ideas please?

Don't use BOLD style for all text of post!!

OK, I'm sorry I annoyed you sir :oops:


[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

Share this post


Link to post
Share on other sites

Well, is that really unreachable? should I lose hope to fix this problem?

Thank you.


[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

Share this post


Link to post
Share on other sites

@EKY32: best is you show us your code and we can see what maybe is not properly coded.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Well, here is my script.. I found the real problem but I don't get the solution yet.

Even when I'm using a huge quantity of items the ListView never flash if it's created

in a normal GUI, and the script works fine, BUT, When I create the ListView in a

TabItem.., the ListView starts flickering when I select the "Show All" string from the

ComboBox (Means when loading all the items from the database), so how to fix that?

Thank you.

The Script File: Products.zip


[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

Share this post


Link to post
Share on other sites

Try this:

#include <GUIConstantsEx.au3>
;~ #include <ComboConstants.au3>;~~~
#Include <GuiComboBox.au3>
#include <GUIListView.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>;~~~
#include <GuiTab.au3>

_SQLite_Startup()
_SQLite_Open(@ScriptDir & "Products.db")

Global $hQuery, $aRow
$hGui = GUICreate("TITLE", 800, 500)
$TabBox = GUICtrlCreateTab(0, 100, 802, 401)
$hTabBox = GUICtrlGetHandle($TabBox)
GUICtrlSetResizing(-1, $GUI_DOCKTOP)
GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
GUICtrlCreateTabItem("1")
GUICtrlCreateLabel("Swich to Tab 2", 20, 50)
GUICtrlCreateTabItem("2")
$ListProducts = GUICtrlCreateListView("1|2|3|4|5|6|7|8|9", -2, 120, 803, 355)
_GUICtrlListView_SetExtendedListViewStyle($ListProducts, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
$hListProducts = GUICtrlGetHandle($ListProducts)
_GUICtrlListView_JustifyColumn($hListProducts, 0, 1)
_GUICtrlListView_JustifyColumn($hListProducts, 1, 1)
_GUICtrlListView_JustifyColumn($hListProducts, 2, 1)
_GUICtrlListView_JustifyColumn($hListProducts, 3, 1)
_GUICtrlListView_JustifyColumn($hListProducts, 4, 1)
_GUICtrlListView_JustifyColumn($hListProducts, 5, 1)
_GUICtrlListView_JustifyColumn($hListProducts, 6, 1)
_GUICtrlListView_JustifyColumn($hListProducts, 7, 1)
_GUICtrlListView_JustifyColumn($hListProducts, 8, 1)
_GUICtrlListView_RegisterSortCallBack($hListProducts)
_GUICtrlListView_SortItems($hListProducts, 8)
$FilterT = GUICtrlCreateCombo("Show All", 254, 477, 145, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlCreateTabItem("3")
GUICtrlCreateTabItem("4")
GUICtrlCreateTabItem("5")
GUICtrlCreateTabItem("6")
GUICtrlCreateTabItem("7")

Loader()
_SQLite_Query(-1, "SELECT ROWID,* FROM Products;", $hQuery)
While _SQLite_FetchData($hQuery, $aRow, False, False) = $SQLITE_OK
    If $aRow[8] <> "" Then GUICtrlSetData($FilterT, $aRow[8])
WEnd
_GUICtrlComboBox_SelectString($FilterT, "Show All")
GUISetState(@SW_SHOW)

_GUICtrlTab_ActivateTab($hTabBox, 1)


While 1
    $RibbonsBar_GetMsg = GUIGetMsg()
    Switch $RibbonsBar_GetMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $FilterT
            _Filter()

    EndSwitch
WEnd

Func Loader()
    _LoadDBTable("Products", $ListProducts)
    GUICtrlSendMsg($ListProducts, $LVM_SETCOLUMNWIDTH, 0, 80)
    GUICtrlSendMsg($ListProducts, $LVM_SETCOLUMNWIDTH, 1, 80)
    GUICtrlSendMsg($ListProducts, $LVM_SETCOLUMNWIDTH, 2, 90)
    GUICtrlSendMsg($ListProducts, $LVM_SETCOLUMNWIDTH, 3, 80)
    GUICtrlSendMsg($ListProducts, $LVM_SETCOLUMNWIDTH, 4, 60)
    GUICtrlSendMsg($ListProducts, $LVM_SETCOLUMNWIDTH, 5, 100)
    GUICtrlSendMsg($ListProducts, $LVM_SETCOLUMNWIDTH, 6, 150)
    GUICtrlSendMsg($ListProducts, $LVM_SETCOLUMNWIDTH, 7, 70)
    GUICtrlSendMsg($ListProducts, $LVM_SETCOLUMNWIDTH, 8, 60)
EndFunc   ;==>Loader

Func _Filter()
    Local $FilterX, $RowF, $hQuery, $aRow, $i = 0
        If GUICtrlRead($FilterT) = "Show All" Then
            _LoadDBTable("Products", $ListProducts)
        Else
            _GUICtrlListView_BeginUpdate($ListProducts)
            _GUICtrlListView_DeleteAllItems($ListProducts)
            _SQLite_Query(-1, "SELECT ROWID,* FROM Products WHERE Filter = '" & GUICtrlRead($FilterT) & "';", $FilterX)
            GUISetState(@SW_LOCK, $hGui)
            While _SQLite_FetchData($FilterX, $aRow, False, False) = $SQLITE_OK
                GUICtrlCreateListViewItem($aRow[1] & "|" & $aRow[2] & "|" & $aRow[3] & "|" & $aRow[8] & "|" & $aRow[4] & "|" & $aRow[5] & "|" & $aRow[6] & "|" & $aRow[7] & "|" & $i + 1, $ListProducts)
                $i = $i + 1
            WEnd
            GUISetState(@SW_UNLOCK , $hGui)
            _GUICtrlListView_EndUpdate($ListProducts)
        EndIf
EndFunc   ;==>_Filter

Func _LoadDBTable($table, $list)
    Local $hQuery, $aNames, $aRow, $i = 0
    _GUICtrlListView_BeginUpdate($list)
    _GUICtrlListView_DeleteAllItems($list)
    _SQLite_Query(-1, "SELECT ROWID,* FROM " & $table & ";", $hQuery)
    GUISetState(@SW_LOCK, $hGui)
    While _SQLite_FetchData($hQuery, $aRow, False, False) = $SQLITE_OK
        If $table = "Products" Then
            GUICtrlCreateListViewItem($aRow[1] & "|" & $aRow[2] & "|" & $aRow[3] & "|" & $aRow[8] & "|" & $aRow[4] & "|" & $aRow[5] & "|" & $aRow[6] & "|" & $aRow[7] & "|" & $i + 1, $list)
        EndIf
        $i = $i + 1
    WEnd
    GUISetState(@SW_UNLOCK , $hGui)
    _GUICtrlListView_EndUpdate($list)
    _GUICtrlListView_SetItemSelected($list, 0)
    _GUICtrlListView_SetItemFocused($list, 0)
EndFunc   ;==>_LoadDBTable

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Oh, that's it Mr.UEZ, you are great!

SO, locking the GUI solved the problem :huh:

Thank you! :wub:


[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0