Print Page | Close Window

Listview HitTest method is broken.

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=15163
Printed Date: 07 July 2024 at 2:16pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Listview HitTest method is broken.
Posted By: ijwelch
Subject: Listview HitTest method is broken.
Date Posted: 14 September 2009 at 2:59am
Hi,

Using version 12.1.1 the listview HitTest method seems to return the first visible item, not the one at X,Y. Something's wrong so suggest CJ make sure fixed before next release.

If anyone needs correct code then this works:



Private Const LVM_FIRST As Long = &H1000
Private Const LVM_HITTEST As Long = (LVM_FIRST + 18)
Private Const LVM_SUBITEMHITTEST As Long = (LVM_FIRST + 57)
Private Const LVHT_NOWHERE As Long = &H1
Private Const LVHT_ONITEMICON As Long = &H2
Private Const LVHT_ONITEMLABEL As Long = &H4
Private Const LVHT_ONITEMSTATEICON As Long = &H8
Private Const LVHT_ONITEM As Long = (LVHT_ONITEMICON Or _
                                    LVHT_ONITEMLABEL Or _
                                    LVHT_ONITEMSTATEICON)
Private Type POINTAPI
   x As Long
   y As Long
End Type

Private Type LVHITTESTINFO
    pt As POINTAPI
    flags As Long
    iItem As Long
    iSubItem As Long 'ie3+ only .. was NOT in win95.
                      'Valid only for LVM_SUBITEMHITTEST
End Type

Private Declare Function SendMessage Lib "user32" _
   Alias "SendMessageA" _
(ByVal hwnd As Long, _
   ByVal wMsg As Long, _
   ByVal wParam As Long, _
   lParam As Any) As Long
   
Public Function ExtremeListView_HitTest(lv As XtremeSuiteControls.ListView, x As Long, y As Long) As XtremeSuiteControls.ListViewItem
Dim HTI As LVHITTESTINFO

'    Set ExtremeListView_HitTest = lv.HitTest(x, y) - this is broken

With HTI
    .pt.x = (x)
    .pt.y = (y)
    .flags = LVHT_ONITEM
End With
      
Call SendMessage(lv.hwnd, LVM_SUBITEMHITTEST, 0, HTI)
If HTI.iItem > -1 Then
    Set ExtremeListView_HitTest = lv.ListItems(HTI.iItem + 1)
End If
End Function


-------------
ExtremeSuitePro 12.1.1
WinXP SP3



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net