Sign in to follow this  
Followers 0
spac3m0nk3y

After updating to 3.2.10.0, Listview will only select first item

8 posts in this topic

I upgraded to AutoIt 3.2.10.0 and tried to recompile a program I had previously working. I had some errors with the Listview functions, but after updating the function names, the program ran. I tried selecting an item from a listview I have, but no matter which item I select it only wants to use the first item in the listview. Is there something I'm missing?

Here is the code for the part that isn't selecting the item:

Func GetGUI()
    $ListViewIndices = _GUICtrlListView_GetSelectedIndices($lstProviders)
    If $ListViewIndices = $LV_ERR Then
        GUICtrlSetData($lblStatus, "Please select a provider first.")
        MsgBox(48, "Alert!", "You must first select a provider.")
        Return
    EndIf

    $ID = _GUICtrlListView_GetItemText($lstProviders, 1)
    $Name = _GUICtrlListView_GetItemText($lstProviders, 0)
    $NumFiles = _FileListToArrayEx($dictationPath, $ID & '*.dss')
    
    If $Inuse = True Then Return
    $Inuse = Not $Inuse
    $getFrm = GUICreate("Get Dictation", 350, 250, -1, -1, -1, -1, $frmMain)
    $dictationGrp = GUICtrlCreateGroup("Dictation Files", 8, 8, 335, 235)
    $getLst = GUICtrlCreateListView("Filename|Size", 16, 25, 220, 210, $LVS_SORTASCENDING, $LVS_EX_CHECKBOXES)
    GUICtrlSendMsg($getLst, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
    GUICtrlSendMsg($getLst, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
    $getBtn = GUICtrlCreateButton("Get Selection", 250, 50, 75, 25, 0)
    GUICtrlSetOnEvent($getBtn, "getDocs")
    $getAllBtn = GUICtrlCreateButton("Get All", 250, 90, 75, 25, 0)
    GUICtrlSetOnEvent($getAllBtn, "getAllDocs")
    $ExitBtn = GUICtrlCreateButton("Exit", 250, 190, 75, 25, 0)
    GUICtrlSetOnEvent($ExitBtn, "GetFrmDel")
    GUISetOnEvent($GUI_EVENT_CLOSE, "GetFrmDel")
    GUISetState(@SW_SHOW)


    If IsArray($NumFiles) Then
        GUICtrlSetData($getLst, '');Empty the control $lstProviders
        For $i = 1 To $NumFiles[0]
            $fileSize = _Bytes_Convert(FileGetSize($dictationPath & $NumFiles[$i]))
            GUICtrlCreateListViewItem($NumFiles[$i] & Chr(124) & $fileSize & Chr(124), $getLst)
        Next
    Else
        GUICtrlSetData($lblStatus, "There are no files for " & $Name)
        MsgBox(48, "No files", "There are no files for " & $Name)
        GetFrmDel()
    EndIf
    
    _GUICtrlListView_SetColumnWidth($getLst, 0, 140)
EndFunc   ;==>GetGUI

Share this post


Link to post
Share on other sites



I had lots of problems witht the nev ver so i am just using 3.2.8.1


[center][/center]

Share this post


Link to post
Share on other sites

I upgraded to AutoIt 3.2.10.0 and tried to recompile a program I had previously working. I had some errors with the Listview functions, but after updating the function names, the program ran. I tried selecting an item from a listview I have, but no matter which item I select it only wants to use the first item in the listview. Is there something I'm missing?

Here is the code for the part that isn't selecting the item:

Func GetGUI()
    $ListViewIndices = _GUICtrlListView_GetSelectedIndices($lstProviders)
    If $ListViewIndices = $LV_ERR Then
        GUICtrlSetData($lblStatus, "Please select a provider first.")
        MsgBox(48, "Alert!", "You must first select a provider.")
        Return
    EndIf

    $ID = _GUICtrlListView_GetItemText($lstProviders, 1)
    $Name = _GUICtrlListView_GetItemText($lstProviders, 0)

    ;...

EndFunc   ;==>GetGUI
A couple of things to check. First, $LV_ERR is not used to indicate failure for _GUICtrlListView_GetSelectedIndices() (see the help file).

Since you did not change the default for $fArray, the result is a pipe delimited string, i.e. "1|3|8".

Once you have that string in $ListViewIndices I don't see you using it again anywhere else in the function...?

The two instances where you use _GUICtrlListView_GetItemText() both have static numeric indicies of 1 and 0, so $ID reads the second item and $Name reads the first item statically.

What items are they meant to read the text from?

:)


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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

A couple of things to check. First, $LV_ERR is not used to indicate failure for _GUICtrlListView_GetSelectedIndices() (see the help file).

Since you did not change the default for $fArray, the result is a pipe delimited string, i.e. "1|3|8".

Once you have that string in $ListViewIndices I don't see you using it again anywhere else in the function...?

I only use $ListViewIndices to check if an item has been selected, if an item has not, then the error message will display.

The two instances where you use _GUICtrlListView_GetItemText() both have static numeric indicies of 1 and 0, so $ID reads the second item and $Name reads the first item statically.

What items are they meant to read the text from?

The listview, $lstProviders, has two items, a name, such as Smith, John and initials, such as JS. They are pipe delimited, "Smith, John|JS".

$ID gets assigned to JS

$Name gets assigned to Smith, John

The function I posted is just one part of the entire program, which is many hundreds of lines of code.

Edited by spac3m0nk3y

Share this post


Link to post
Share on other sites

I only use $ListViewIndices to check if an item has been selected, if an item has not, then the error message will display.

The listview, $lstProviders, has two items, a name, such as Smith, John and initials, such as JS. They are pipe delimited, "Smith, John|JS".

$ID gets assigned to JS

$Name gets assigned to Smith, John

The function I posted is just one part of the entire program, which is many hundreds of lines of code.

You'll need to post a "reproducer". A short demo script that has just enough in it to show your symptoms. I don't see your issue in my own scripts, and you didn't post enough code to see it in yours.

:)


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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Here is a really simple example of what I'm trying to do.

No matter which item I click on, it only returns the first item.

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

Opt('MustDeclareVars', 1)
Opt("GUIOnEventMode",1)

$Debug_LV = False 

Local $GUI, $hListView, $YesID

$GUI = GUICreate("(External) ListView Get Item Text", 400, 300)
$YesID  = GUICtrlCreateButton("Yes", 50, 190, 50, 20)
GUICtrlSetOnEvent($YesID,"OnYes")
$hListView = GUICtrlCreateListView("Items|Extend", 2, 2, 200, 100)
GUISetState()

; Add items
GUICtrlCreateListViewItem ("Item 1|Extend 1", $hListView)
GUICtrlCreateListViewItem ("Item 2|Extend 2", $hListView)
GUICtrlCreateListViewItem ("Item 3|Extend 3", $hListView)

GUISetOnEvent($GUI_EVENT_CLOSE,"OnExit")

GUISetState()  ; display the GUI

While 1
   Sleep (1000)
WEnd

Func OnYes()
    MsgBox (4160, "Information", _GUICtrlListView_GetItemText($hListView, 0))
EndFunc   ;==>Example_External

Func OnExit()
    Exit
EndFunc
Edited by spac3m0nk3y

Share this post


Link to post
Share on other sites

I think I got it.

Instead of using

_GUICtrlListView_GetItemText($hListView, 0)oÝ÷ جy«­¢+ØÀÌØíÑÉÉäô}U%
Ñɱ1¥ÍÑY¥Ý}Ñ%ѵQáÑÉÉä ÀÌØí¡1¥ÍÑY¥Ü°´Ä

and use $tArray[1] for the Name and $tArray[2] for the ID.

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