Jump to content

Little problem with listbox


manofman
 Share

Recommended Posts

hi i have a little problem with listbox i get the handle but after that i can get the number of item on the list that cause that i can get the text.

i try to put the number of item on a var and after get the text on var var with the number of line in my first var.

like this

$ghwd = ControlGetHandle ( "Prog Title", "", "[ID:771]" )
$Lget = _GUICtrlListBox_GetCount ( $ghwd )
$Lfind = _GUICtrlListBox_GetText ( $ghwd , $Lget )

Anyone have an idea please i try a lot of things but can find whats wrong and yes i have include the file GuiListBox.au3 and if this can help my code is on a function

oh and by the way $Lget return always 0

Thank you

Link to comment
Share on other sites

This returns the count, exactly as expected: $Lget = _GUICtrlListBox_GetCount($ghwd)

But this needs a zero-based index: $Lfind = _GUICtrlListBox_GetText($ghwd, $Lget - 1)

That should return the text of the last item in $Lfind. If you want them all in an array:

$ghwd = ControlGetHandle ( "Prog Title", "", "[ID:771]" )
$Lget = _GUICtrlListBox_GetCount($ghwd)
Global $avLfind[$Lget]
For $i = 0 To $Lget - 1
    $avLfind[$i] = _GUICtrlListBox_GetText($ghwd, $i)
Next

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

This returns the count, exactly as expected: $Lget = _GUICtrlListBox_GetCount($ghwd)

But this needs a zero-based index: $Lfind = _GUICtrlListBox_GetText($ghwd, $Lget - 1)

That should return the text of the last item in $Lfind. If you want them all in an array:

$ghwd = ControlGetHandle ( "Prog Title", "", "[ID:771]" )
$Lget = _GUICtrlListBox_GetCount($ghwd)
Global $avLfind[$Lget]
For $i = 0 To $Lget - 1
    $avLfind[$i] = _GUICtrlListBox_GetText($ghwd, $i)
Next

:)

Thank you so much
Link to comment
Share on other sites

Only one problem

$Lget = _GUICtrlListBox_GetCount($ghwd) that always retyurn an index of 0 thats strange

Are you sure it's a listbox? What's the class or CLASSNN of the control? If you look at the example in the help file under _GuiCtrlListBox_GetCount(), you'll see an option to enable debug messages. Run this demo to see what that does:

#include <GUIListBox.au3>

$Debug_LB = True ; Check ClassName being passed to ListBox functions

Run("Notepad.exe")
$hListBox = ControlGetHandle("Untitled - Notepad", "", "Edit1")
$iCnt = _GUICtrlListBox_GetCount($hListBox)

MsgBox(64, "Results", "$iCnt = " & $iCnt)

WinClose("Untitled - Notepad")oÝ÷ Ø]¶¬)Þ¶azÚ)¡ü¨º»®*mjwlyì!jܨº­jëh×6Global $Debug_LB = True

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...