Sign in to follow this  
Followers 0
NeuroToxic

problem with listview and checkbox

9 posts in this topic

Hi all,

First, sorry for my bad english, i'm french.

I have a problem with a listview and checkbox in this listview.

In my listview I have few items.

I developed a function that will return the number of items checked in listview.

It work very well, but just when an item is selected and checked simultaneously, this item is not count.

I also noticed that in AutoIt Help, such "_GUICtrlListViewGetCheckedState" example, the same problem appears.

Its a bug or not ?

Have you got a solution ?

Thank you

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Nobody can answer me ?

It is a bug of an UDF of AutoIt and in the last version of AutoIt its the same problem

Edited by NeuroToxic

Share this post


Link to post
Share on other sites

Answers come faster when the question has example code to reproduce the problem.


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

this code reproduce the problem :

#include <GuiListView.au3>

Opt('MustDeclareVars', 1)

Example_Internal()

Func Example_Internal()
    Local $hListView
    Local $button_test
    
    GUICreate("(Internal) ListView Get Item Checked State", 310, 300)
    $hListView = GUICtrlCreateListView("", 2, 2, 306, 268)
    _GUICtrlListView_SetExtendedListViewStyle ($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
    GUISetState()
    
    ; Add columns
    _GUICtrlListView_AddColumn ($hListView, "Column 1", 100)
    _GUICtrlListView_AddColumn ($hListView, "Column 2", 100)
    _GUICtrlListView_AddColumn ($hListView, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem ($hListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem ($hListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem ($hListView, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem ($hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem ($hListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem ($hListView, "Row 3: Col 1", 2)

    $button_test = GUICtrlCreateButton("test", 100, 273, 100, 25)

    ; Loop until user exits
    While 1
        Local $msg = GUIGetMsg()
        Select
            
            Case $msg = $GUI_EVENT_CLOSE
                GUIDelete()
                ExitLoop
                        
            Case $msg = $button_test
;~              check if item 2 is checked
                MsgBox (4160, "Information", "Item 2 Checked: " & _GUICtrlListView_GetItemChecked ($hListView, 1))
                
        EndSelect
    WEnd

EndFunc   ;==>Example_Internal

it test if the item 2 is checked or not when I click on the button "Test".

The problem appears when I check the item 2 and I select it at the same time.

This code is partially the code used in example of AutoIt Help (version : 3.2.10.0) (udf: _GUICtrlListView_GetItemChecked)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

That example does not reproduce your problem, it works just fine - if Item2 checkbox is checked, its state is reported as True no matter if the row #2 is selected or not. Tested with 3.2.10.0

Anyway, your problem sounds like a trivial case of not following the AutoIt manual, and doing the GUICtrlRead state flag check by using simple value compare instead of BitAND() like documented.

Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

No it's not the problem.

Reproduce the following procedure :

-- check the item 2

-- select the item 2

-- press the button "Test"

The result is False and not True, this is the problem.

The problem appears when the item 2 is checked and selected at the same time.

Share this post


Link to post
Share on other sites

No it's not the problem.

Reproduce the following procedure :

-- check the item 2

-- select the item 2

-- press the button "Test"

The result is False and not True, this is the problem.

The problem appears when the item 2 is checked and selected at the same time.

Works fine for me in 3.2.10.0


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

Sorry, I completely uninstalled AutoIt and Scite, I reinstalled, and now it works fine.

I think it was a bug of an old beta version of AutoIt.

thank you for your help :)

Share this post


Link to post
Share on other sites

That example does not reproduce your problem, it works just fine - if Item2 checkbox is checked, its state is reported as True no matter if the row #2 is selected or not. Tested with 3.2.10.0

Anyway, your problem sounds like a trivial case of not following the AutoIt manual, and doing the GUICtrlRead state flag check by using simple value compare instead of BitAND() like documented.

Only for clarification:

Here is related code that Siao was talking about:

Func IsChecked($control)
    Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED
EndFunc

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