Jump to content

_GUICtrlListBox


jugador
 Share

Recommended Posts

Having problem using _GUICtrlListBox

$iTitle = "Something"

Local $hdlWindow = WinGetHandle($iTitle )
Local $Ad_Mode = "[CLASS:ListBox; INSTANCE:4]"
Local $hControl = ControlGetHandle($hdlWindow, "", $Ad_Mode)

;;this working
_GUICtrlListBox_ClickItem($hControl, 1, "left",False)

;;but this return empty
Local $iCnt = _GUICtrlListBox_GetCount($hControl)
MsgBox($MB_SYSTEMMODAL, "", "Column " & $iCnt)

Listbox.JPG.e3344111e5989c0cd3319f8a84761658.JPG

Link to comment
Share on other sites

Hi jugador,
When I insert your partial code into the help file example (_GUICtrlListBox_GetCount) then your script works fine :

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
     GUICreate("List Box Get Count", 400, 296)

    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)

    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Get item count
    MsgBox($MB_TOPMOST, "Information", "Item count: " & _GUICtrlListBox_GetCount($idListBox))

    ; ====================
    ; begin jugador script
    ; ====================
    $iTitle = "List Box Get Count"

    Local $hdlWindow = WinGetHandle($iTitle )
    Local $Ad_Mode = "[CLASS:ListBox; INSTANCE:1]"
    Local $hControl = ControlGetHandle($hdlWindow, "", $Ad_Mode)

    ;;this working
    _GUICtrlListBox_ClickItem($hControl, 1, "left",False)

    ;;but this return empty
    Local $iCnt = _GUICtrlListBox_GetCount($hControl)
    MsgBox($MB_SYSTEMMODAL, "jugador", "Column " & $iCnt)
    ; ==================
    ; end jugador script
    ; ==================

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

_GUICtrlListBox_GetCount.png.84f30588451f876846743466f1f97e34.png

I just changed your window title and  INSTANCE:4 to INSTANCE:1 to match the help file example.
If this doesn't help, could you please post your whole script (including Gui creation & other controls) so we can determine why it is not working at your place ?

Edited by pixelsearch
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...