Sign in to follow this  
Followers 0
dazza

Listboxes that clear themselves...

10 posts in this topic

I populate a listbox with lines from a file. I see the listbox being filled up but then at the end--it clears itself! :)

$calls is the name of the listbox

; extract file

$file_name = GUICtrlRead($config)

$file = FileOpen($file_name, 0)

while 1

$line = FileReadLine($file)

GUICtrlSetData($calls, $line)

Wend

FileClose($file)

Share this post


Link to post
Share on other sites



I populate a listbox with lines from a file. I see the listbox being filled up but then at the end--it clears itself! :)

The last line in the file is NUL so GUICtrlSetData() takes the NUL and clear the listbox

Change:

GUICtrlSetData($calls, $line)oÝ÷ Ù:ºÚ"µÍY    ÌÍÛ[H    ÉÝÈ  ][ÝÉ][ÝÈ[ÕRPÝÙ]]J    ÌÍØØ[Ë ÌÍÛ[J

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

while 1

$line = FileReadLine($file)

GUICtrlSetData($calls, $line)

Wend

need to be

$ct=0
do 
$line = Filereadline($file,$ct)
guictrlsetda($calls,$line)
$ct+=1
until @error = -1
Edited by Aceguy

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Works a treat. Many thanks. :)

Now...

I need a loop that processes each item of the listbox

eg

While not end of listbox

alpha = listbox(next_item)

do_stuff(alpha)

Wend

Edited by dazza

Share this post


Link to post
Share on other sites

use

#Include <GuiListBox.au3>
$count = _GUICtrlListBox_GetCount(GUICtrlGetHandle($ListBox))

For $index = 1 To $count-1
_GUICtrlListBox_GetText(GUICtrlGetHandle($ListBox),$index)
Next

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

My build doesn't have GuiListBox3. :)

Is there a way of extracting each item (and having it selected) without the above?

Share this post


Link to post
Share on other sites

My build doesn't have GuiListBox3. :)

Is there a way of extracting each item (and having it selected) without the above?

;~ $LB_GETCOUNT = 0x18B
;~ $LB_GETTEXT = 0x189

    $hwnd_lb = ControlGetHandle("Your title","","ListBox1")
    $count = dllcall("user32.dll","int","SendMessage","hWnd",$hwnd_lb,"int",$LB_GETCOUNT,"int",0,"int",0)

    For $i = 0 to $count[0] - 1
        $line_text = dllcall("user32.dll","int","SendMessage","hWnd",$hwnd_lb,"int",$LB_GETTEXT,"int",$i,"str","")
        $line_text = $line_text[4] 
        ConsoleWrite($line_text & @LF)
    Next

Share this post


Link to post
Share on other sites

This code picks out each member of the list beautifully--many thanks.

Is there a way I can highlight each member as it's processed.

i.e. make the 7th member (of the listbox) selected (darkened out)

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