Sign in to follow this  
Followers 0
Jakobud

_GUICtrlListView_GetItemTextString broken?

3 posts in this topic

#1 ·  Posted (edited)

This is weird. It seems to work fine in the included examples but when I try to use it in this simple example GUI I made it doesn't work.

Basically this gui simply fills out a few things in the listview. When you select one of those listview items and hit the button, it is supposed to tell you what the value/text of that listview item is. But it just comes up blank. What am I doing wrong?

#include <GUIConstants.au3>
#Include <GuiListView.au3>

Opt("GUIOnEventMode", 1)
AutoItSetOption("GUICoordMode",0)

$GUI = GUICreate("Test",320,450,-1,-1)
GUISetOnEvent($GUI_EVENT_CLOSE, "EVENT_CLOSE")

$startButton = GUICtrlCreateButton("button",5,5,100,30)
GUICtrlSetOnEvent($startButton, "EVENT_START")

;Create the Listview
AutoItSetOption("GUICoordMode",1)
$listview = GUICtrlCreateListView ("",5,40,308,370,0x0014,0x00000001)

_GUICtrlListView_AddColumn($listview, "Host", 200)
_GUICtrlListView_AddColumn($listview, "Active", 75)

_GUICtrlListView_AddItem($listview,"hello")
_GUICtrlListView_AddItem($listview,"world")

GUISetState(@SW_SHOW)

; Main Loop
While 1
    Sleep(1000)
Wend

Func EVENT_START()
    Local $index = _GUICtrlListView_GetSelectedIndices($listview)  ;<-- Determine the index of the selected listview item
    MsgBox(0,'',"Selected index is " & $index)
    $text = _GUICtrlListView_GetItemTextString($listview, $index)  ;<--- Use the above index to determine the text/value of the selected listview item
    MsgBox(0,'',"The value of that item is " & $text)   ;<--- supposed to say "hello" or "world" when you have one of those items selected but it comes up blank
EndFunc

Func EVENT_CLOSE()
    Exit
EndFunc

I've had similar experience with _GUICtrlListView_GetItem, _GUICtrlListView_GetItemText and _GUICtrlListView_GetItemTextArray. They just all return blank values.

Edited by Jakobud

Share this post


Link to post
Share on other sites



read the help on the return value of the function(s) and that would help you resolve your problem.

Nothing broken about it.

#include <GUIConstants.au3>
#include <GuiListView.au3>

Opt("GUIOnEventMode", 1)
AutoItSetOption("GUICoordMode", 0)

$GUI = GUICreate("Test", 320, 450, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "EVENT_CLOSE")

$startButton = GUICtrlCreateButton("button", 5, 5, 100, 30)
GUICtrlSetOnEvent($startButton, "EVENT_START")

;Create the Listview
AutoItSetOption("GUICoordMode", 1)
$listview = GUICtrlCreateListView("", 5, 40, 308, 370, 0x0014, 0x00000001)

_GUICtrlListView_AddColumn($listview, "Host", 200)
_GUICtrlListView_AddColumn($listview, "Active", 75)

_GUICtrlListView_AddItem($listview, "hello")
_GUICtrlListView_AddItem($listview, "world")

GUISetState(@SW_SHOW)

; Main Loop
While 1
    Sleep(1000)
WEnd

Func EVENT_START()
    Local $index = Int(_GUICtrlListView_GetSelectedIndices($listview)) ;<-- Determine the index of the selected listview item
    MsgBox(0, '', "Selected index is " & $index)
    $text = _GUICtrlListView_GetItemTextString($listview, $index) ;<--- Use the above index to determine the text/value of the selected listview item
    MsgBox(0, '', "The value of that item is " & $text) ;<--- supposed to say "hello" or "world" when you have one of those items selected but it comes up blank
EndFunc   ;==>EVENT_START

Func EVENT_CLOSE()
    Exit
EndFunc   ;==>EVENT_CLOSE

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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