Jump to content

Possible bug in _GUICtrlListview_Clickitem with column width wider than listview control size


Recommended Posts

If the combined column width in the listview is larger than the listview control size then the _GUICtrlListview_Clickitem function tries clicking in the center of the combined column width which may be outside of the clickable area of the listview control.

Is this a bug in _GUICtrlListview_Clickitem or is it something in my code?

This is a modification of the example in the help file for _GUICtrlListView_Clickitem:

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global $hListView

_Main()

Func _Main()
    ; Create GUI
    GUICreate("ListView Click Item", 400, 300)
    $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState()

    ; Add columns
    _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 500)
    _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 500)
    
    ; Add items
    _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)
    
    _GUICtrlListView_ClickItem($hListView, 1, "left", False, 2)
    
    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

Also, is there a programmatic way of selecting something in the listview that does not depend on the listview being in the visible area? I looked at the code for GUICtrlListview_Clickitem and it seems to be using MouseClick to do the selection.

EDIT: Tracking this with the following bug: http://svn.autoitscript.com/trac/ticket/510

Edited by duckling78
Link to comment
Share on other sites

If the combined column width in the listview is larger than the listview control size then the _GUICtrlListview_Clickitem function tries clicking in the center of the combined column width which may be outside of the clickable area of the listview control.

Is this a bug in _GUICtrlListview_Clickitem or is it something in my code?

This is a modification of the example in the help file for _GUICtrlListView_Clickitem:

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global $hListView

_Main()

Func _Main()
; Create GUI
    GUICreate("ListView Click Item", 400, 300)
    $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState()

; Add columns
    _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 500)
    _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 500)
    
; Add items
    _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)
    
    _GUICtrlListView_ClickItem($hListView, 1, "left", False, 2)
    
; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc ;==>_Main

Also, is there a programmatic way of selecting something in the listview that does not depend on the listview being in the visible area? I looked at the code for GUICtrlListview_Clickitem and it seems to be using MouseClick to do the selection.

EDIT: Tracking this with the following bug: http://svn.autoitscript.com/trac/ticket/510

Interesting side effect of how *_ClickItem picks its X/Y coordinates. To see another, try it this way:
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global $hGUI, $hListView, $idButton

_Main()

Func _Main()
; Create GUI
    $hGUI = GUICreate("ListView Click Item", 400, 300)

; Create ListView
    $hListView = _GUICtrlListView_Create($hGUI, "", 5, 5, 390, 235)
; Add columns
    _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 500)
    _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 500)
; Add items
    _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)

; Add Button
    $idButton = GUICtrlCreateButton("Click Item", 150, 265, 100, 30)
    
; Show GUI
    GUISetState()

; Loop until user exits
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $idButton
                _GUICtrlListView_ClickItem($hListView, 1, "left", True, 2)
        EndSwitch
    WEnd
EndFunc ;==>_Main

When you click the button, it will click the item. I changed the mouse movement to True so you can see where it goes. Having the button trigger it gives you time to move the horizontal scroll on the listview. Try it when it first comes up, then try it again with the scroll way to the right.

:P

P.S. According to your BugTrac, it's fixed in 3.2.13.8 Beta.

:P

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

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...