Sign in to follow this  
Followers 0
TheCuz

Problem with list view

9 posts in this topic

Hello,

I am having a problem with adding items to a list view. What the script is supposed to do is open a text file as an array and display certain lines of the text file in a list view. Problem is that when it gets to a certain number of entries in the list view (4096 every time), GUICtrlCreateListViewItem returns a failure and does not add any more entires.

Another thing is that there is 4789 entries in the text file that should show up, but it stops adding after 4095. I have another part of the program that does the same thing, but with a different text file, and it can add over 10,000 entires without any problems.

Any help/suggestions on how to find out what is going on or what is causing this problem would be greatly appericated. The *.au3 and text file are attached.

Thanks in advance.

Notes:

Running AutoIt version 3.2.8.1

#include <GUIConstants.au3>
#include <guilistview.au3>

$main = GUICreate("Inventory Comapre", 826, 507, 295, 153, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_OVERLAPPEDWINDOW,$WS_TILEDWINDOW,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS))
$lvVs = GUICtrlCreateListView("ID|CREATE DATE|<N/A>", 416, 8, 400, 454, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES))
_GUICtrlListViewSetColumnWidth($lvVs, 0, 80)
_GUICtrlListViewSetColumnWidth($lvVs, 1, 200)
GUICtrlSetResizing($lvVs, $GUI_DOCKBOTTOM + $GUI_DOCKTOP)

GUISetState(@SW_SHOW)

$vsDb = FileOpenDialog("Video Server File", "C:\", "Text Files(*.txt)")
_ParseFile($vsDb, "vidsrvr")

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

    EndSwitch
WEnd


Func _DateParse($sDate)
    
    $vidDate = StringLeft($sDate, 13)
    $strpWspc = StringStripWS($vidDate, 8)
    $dtSplt = StringSplit($strpWspc, "-")
    Dim $mnth, $day, $yr
    
    $day = $dtSplt[1]
    $yr = StringRight($dtSplt[3], 2)
    Switch $dtSplt[2]
        Case "Jan"
            $mnth = 01
        Case "Feb"
            $mnth = 02
        Case "Mar"
            $mnth = 03
        Case "Apr"
            $mnth = 04
        Case "May"
            $mnth = 05
        Case "Jun"
            $mnth = 06
        Case "Jul"
            $mnth = 07
        Case "Aug"
            $mnth = 08
        Case "Sep"
            $mnth = 09
        Case "Oct"
            $mnth = 10
        Case "Nov"
            $mnth = 11
        Case "Dec"
            $mnth = 12
    EndSwitch
    
    Return $mnth & "/" & $day & "/" & $yr & chr(32) & StringMid($sDate, 14, 11)             
    
EndFunc

Func _ParseFile($sFile, $sType) 
    $readFile = FileRead($sFile)    
    $LnSplt = StringSplit(StringStripCR($readFile), @LF, 1)
    $RcdsFnd = 1

        For $aLn = 4 To ($LnSplt[0] - 8)
            If StringInStr($LnSplt[$aLn], "-inc") = 0 Then
                If StringInStr($LnSplt[$aLn], ".vix") = 0 Then
                $date = _DateParse($LnSplt[$aLn])
                $lvci = GUICtrlCreateListViewItem(StringMid($LnSplt[$aLn], 50, 8) & " | " & $date, $lvVs)
                If $lvci = 0 then ConsoleWrite("ERROR{" & $RcdsFnd & "} - could not add to list view" & @CRLF)
                ConsoleWrite("[video server]$RcdsFnd = " & $RcdsFnd & @CRLF)
                $RcdsFnd += 1
                EndIf           
            EndIf
        Next    
EndFunc

[font="Verdana"]People who say it cannot be done should not interrupt those who are doing it. - George Benard Shaw[/font]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

GUICtrlCreateListViewItem() creates window control for each listview item and there is limit 4096 controls in AutoIt application.

So instead of GUICtrlCreateListViewItem() use _GUICtrlListViewInsertItem()

Edited by Zedna

Share this post


Link to post
Share on other sites

Thanks for the reply Zedna :)

Just an FYI, the other part of the program which I am doing the exact same thing, allowed me to add over 10,000 items to the list view. Any ideas as to why it would let me add that many items to the list view and not the other.


[font="Verdana"]People who say it cannot be done should not interrupt those who are doing it. - George Benard Shaw[/font]

Share this post


Link to post
Share on other sites

Thanks for the reply Zedna :)

Just an FYI, the other part of the program which I am doing the exact same thing, allowed me to add over 10,000 items to the list view. Any ideas as to why it would let me add that many items to the list view and not the other.

Hi.

Not possible; please show your code; maybe you used "ListBox" rather than "ListView"? - or used InsertItem instead of createItem?

Best, Randall

Share this post


Link to post
Share on other sites

Hi randallc,

Attached is the code and text files used for this project.

What this will do is when it adds the items from the automation file (the first run through the _ParseFile function), it will add all of the lines from that file to the list view (which ends up being 10,000 items), but then when it tries to go through the video server file, GUICtrlCreateListViewItem returns zero when it tries to add the first line that matches the criteria.

I am just really curious about why:

1) with the automation file, you can add over 10,000 items to the list view when using GUICtrlCreateListViewItem

2) when it tries to add the found items from the video server file, it chokes on the first one

3) [interesting] if you comment out the FileOpenDialog and function that runs the automation file (lines 19 & 22), it will then add the video server items, but stop working after 4095 items have been added to the video server inventory (right hand list view) using the same GUICtrlCreateListViewItem function as I did to add items to the automation inventory list view

I appreciate any feedback on this. Currently I do have the script working correctly after using the suggestion offered by Zedna, but I would like to know why it does this so I can understand this quirk of AutoIt.

Thanks for the help. :)


[font="Verdana"]People who say it cannot be done should not interrupt those who are doing it. - George Benard Shaw[/font]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

but I would like to know why it does this so I can understand this quirk of AutoIt.

You've already been told why this happens. Due to limited number of controls Autoit can create in a GUI.

In your example files.zip:

If you run as is, it creates 4094 items in first listview (not 10000+ like you state), and none in second listview because the limit is reached.

If you switch places these lines:

_ParseFile($autDb, "automation")

_ParseFile($vsDb, "vidsrvr")

it creates 4094 items in second listview and none in first, again, as it should given current limit.

Your observations are completely off base

:)

Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

Hi,

Test for creation success as you go..

$i_LVitemID=GUICtrlCreateListViewItem(StringMid($LnSplt[$aLn], 13, 8) & "|" & StringMid($LnSplt[$aLn], 48, 32) & "|" & StringMid($LnSplt[$aLn], 181, 12), $lvAut)
                ConsoleWrite("[automation]$RcdsFnd = " & $RcdsFnd & @CRLF)
                if not $i_LVitemID then return
and you will see the painful 4095 number as last successful Created iem...

Best, Randall

Share this post


Link to post
Share on other sites

After looking at my script, I didn't see that I wasn't checking for the "automation" part of the function to see if it was getting an error from the create list view item.

I added a check for that part like I did for the other one and see that it is stopping at the same point the other one was.

Sorry for wasting your time!


[font="Verdana"]People who say it cannot be done should not interrupt those who are doing it. - George Benard Shaw[/font]

Share this post


Link to post
Share on other sites

Hi,

Test for creation success as you go..

$i_LVitemID=GUICtrlCreateListViewItem(StringMid($LnSplt[$aLn], 13, 8) & "|" & StringMid($LnSplt[$aLn], 48, 32) & "|" & StringMid($LnSplt[$aLn], 181, 12), $lvAut)
                ConsoleWrite("[automation]$RcdsFnd = " & $RcdsFnd & @CRLF)
                if not $i_LVitemID then return
and you will see the painful 4095 number as last successful Created iem...

Best, Randall

Thanks randallc :) I was creating the reply just as you posted.

I did something similar to what you had done. I just wasn't really seeing what was happening in that part, and was why I was questioning that I was seeing in the console that it was getting to over 10,000 items.

Guess I shouldn't code when I am tired.


[font="Verdana"]People who say it cannot be done should not interrupt those who are doing it. - George Benard Shaw[/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