Sign in to follow this  
Followers 0
MrSergey

How to accelerate ListView creation?

7 posts in this topic

Hi,

Sorry for my english...

It's my code:

#include <GUIConstants.au3>
#Include <GuiListView.au3>

$GUI = GUICreate("Listview", 300,300)
$hListView = GuiCtrlCreateListView("1|2|3|4|5|6|7", 10, 10, 280, 290,-1, BitOR($LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT ))

$x = 100

For $i = 0 to $x
    GUICtrlCreateListViewItem("1|2|3|4|5|6|7", $hListView)
Next

GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
    Sleep(10)
WEnd

If $x small then all work fast, but if $x > 1000 then the window is created too long.

In my program I need use $x = 50000. Time of window creation = 1 min. It's VERY long.

How I can accelerate process of window creation?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You could use the GuiListView UDF. Function _GUICtrlListView_AddArray adds items from an array to the control

See User Defined Functions -> GuiListView Management in the help file.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I've used version of this for listviews with > 100,000 rows. Note it may be missing includes for the current version of AutoIt.

Edited by picaxe

Share this post


Link to post
Share on other sites

I've used version of this for listviews with > 100,000 rows

Thanks!!! It's realy fast!!!

But how I can use the given code for my creation ListView?

Code very long and difficult. Probably exists UDF on ListView with use of the given code?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

#include <GUIConstants.au3>
#Include <GuiListView.au3>

$GUI = GUICreate("Listview", 300,300)
$hListView = GuiCtrlCreateListView("1|2|3|4|5|6|7", 10, 10, 280, 290,-1, BitOR($LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT ))

$x = 100000
_GUICtrlListView_BeginUpdate($hListView)
For $i = 0 to $x
    GUICtrlCreateListViewItem("1|2|3|4|5|6|7", $hListView)
Next
_GUICtrlListView_EndUpdate($hListView)
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
    Sleep(10)
WEnd

added :

1. _GUICtrlListView_BeginUpdate($hListView)

2. _GUICtrlListView_EndUpdate($hListView)

Edited by psandu.ro

Share this post


Link to post
Share on other sites

Now I randomly noticed there is _GUICtrlListView_AddArray() function which is based on the same optimization idea!!

>_<

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