Jump to content

Listboxes that clear themselves...


dazza
 Share

Recommended Posts

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)

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

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

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