Jump to content

How do I access all the List control contents


sshrum
 Share

Recommended Posts

I'm writing a debug console that I can send msgs to. Basically its just a gui window with a List control.

When the app closes, I'd like to save all the entries that were sent to the list to a file.

When I run the GUICTRLREAD, I just get the first entry.

I was hoping I'd get back a large '|' separated string of everything in the control.

What do I need to do to get all the entries?

TIA

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Link to comment
Share on other sites

sshrum

Example:

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <Array.au3> ;Only for _ArrayDisplay()

$hGUI = GUICreate("Test", 300, 200)

$ListBox = GUICtrlCreateList("", 10, 10, 280, 160)

GUICtrlSetData(-1, "Hello world|AutoIt rulezzz")

$button = GUICtrlCreateButton("Get", 10, 170, 75, 23)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $button
            $Strings = _GetAllItemsText()
            _ArrayDisplay($Strings)
    EndSelect
WEnd

Func _GetAllItemsText()
    Local $iCount, $i
    
    $iCount = _GUICtrlListBox_GetCount($ListBox)
    Local $aStrings[$iCount + 1] = [$iCount]
    
    For $i = 1 To $aStrings[0]
        $aStrings[$i] = _GUICtrlListBox_GetText($ListBox, $i - 1)
    Next
    
    Return $aStrings
EndFunc

:P

Link to comment
Share on other sites

That sorta works (doesn't seem to see all the entries in the list). But I also found out that the list is sorting my entries alphabetically which isn't what I want (need them in the order I send them).

Started using the Edit object and that seems to work more to the way I want...keeps the order and outputs 1 string on GUICTRLREAD so I can do a simple FILEWRITE of the return.

thanks again.

Edited by sshrum

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...