smashly Posted July 1, 2008 Posted July 1, 2008 (edited) Hi, While using XP SP2, Autoit 3.2.12.1 & 3.2.13.3 I'm getting a wrong return from _GUICtrlListView_HitTest() at [4] - If True, position is over item state image. It only happens when using the ex styles $LVS_EX_CHECKBOXES & $LVS_EX_FULLROWSELECT using internal or externally added items. Clicking anything in the first column works like it should and returns correclty, but it's returning true when clicking any subitem in any other column. Stripped Example of what's wrongexpandcollapse popup#include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) $Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work Global $hListView, $iIndex = -1 _Main() Func _Main() Local $GUI ; Create GUI $GUI = GUICreate("ListView Hit Test", 400, 300) $hListView = GUICtrlCreateListView("", 2, 2, 394, 268) $hListView = GUICtrlGetHandle($hListView) ; get the handle for use in the notify events ; Enable extended control styles _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT)) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; 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, 1) _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2, 2) _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1, 2) _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2) ; Loop until user exits While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() EndFunc ;==>_Main Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button Local $aHit = _GUICtrlListView_HitTest($hListView) _DebugPrint("$NM_CLICK" & @LF & "--> $aHit[0] = " & @TAB & $aHit[0] & @LF & _ "--> $aHit[1] = " & @TAB & $aHit[1] & @LF & _ "--> $aHit[2] = " & @TAB & $aHit[2] & @LF & _ "--> $aHit[3] = " & @TAB & $aHit[3] & @LF & _ "!!> $aHit[4] = " & @TAB & $aHit[4] & @LF & _ "--> $aHit[5] = " & @TAB & $aHit[5] & @LF & _ "--> $aHit[6] = " & @TAB & $aHit[6] & @LF & _ "--> $aHit[7] = " & @TAB & $aHit[7] & @LF & _ "--> $aHit[8] = " & @TAB & $aHit[8] & @LF & _ "--> $aHit[5] = " & @TAB & $aHit[9] & @LF) ; No return value EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _DebugPrint($s_text, $line = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @LF & _ "+======================================================" & @LF & _ "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _ "+======================================================" & @LF) EndFunc ;==>_DebugPrintEdit: I did also try setting the X & Y pos of the hit test, but that didn't fix it either. Am I missing a trick or something? Cheers Edited July 1, 2008 by smashly
Siao Posted July 1, 2008 Posted July 1, 2008 Use _GUICtrlListView_SubItemHitTest "be smart, drink your wine"
smashly Posted July 1, 2008 Author Posted July 1, 2008 Hi, Thank You for the response. Yep that was the workaround I used before posting, it just meant I had to use another bool in my NM_CLICK, feels like my code just gets longer and longer for something I'm not wanting to check. Ahh well that's life. Cheers
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now