'code snippets
Private Function CellFromPoint(ByVal xPixels As Long, ByVal yPixels As Long, ByRef Row As Long, ByRef Cell As Long)
'/* mouse pointer over item
Dim tLVHT As LVHITTESTINFO
'/* get target item index
Row = -1
Cell = -1
If Not (Me.ItemCount = 0) Then
tLVHT.pt.x = xPixels
tLVHT.pt.y = yPixels
SendMessage m_hListView, LVM_HITTEST, 0&, tLVHT
If (tLVHT.iItem <= 0) Then
If (tLVHT.flags And LVHT_NOWHERE) = LVHT_NOWHERE Then
Row = -1
Else
Row = tLVHT.iItem
End If
Else
Row = tLVHT.iItem
End If
End If
'/* cell hit test
If Not (Me.ItemCount = 0) And Not Row = -1 Then
With tLVHT
.pt.x = xPixels
.pt.y = yPixels
.flags = LVHT_ONITEM
End With
'/* hit test
SendMessage m_hListView, LVM_SUBITEMHITTEST, 0&, tLVHT
Cell = tLVHT.iSubItem
End If
End Function
Private Function LVScrollVertical(ByVal bDown As Boolean)
'/* scroll vertical
If bDown Then
SendMessageLong m_hListView, WM_VSCROLL, SB_LINEDOWN, 0 'LVM_SCROLL
Else
SendMessageLong m_hListView, WM_VSCROLL, SB_LINEUP, 0
End If
End Function
Private Function LVScrollHorizontal(ByVal bRight As Boolean)
'/* scroll horizontal
If bRight Then
SendMessageLong m_hListView, WM_HSCROLL, SB_LINERIGHT, 0
Else
SendMessageLong m_hListView, WM_HSCROLL, SB_LINELEFT, 0
End If
End Function
Private Function LVHasHorizontal() As Boolean
'/* vertical scrollbar test
Dim lStyle As Long
If m_bIsNt Then
lStyle = GetWindowLongW(m_hListView, GWL_STYLE)
Else
lStyle = GetWindowLong(m_hListView, GWL_STYLE)
End If
LVHasHorizontal = (lStyle And WS_HSCROLL) <> 0
End Function
Private Function LVHasVertical() As Boolean
'/* horizontal scrollbar test
Dim lStyle As Long
If m_bIsNt Then
lStyle = GetWindowLongW(m_hListView, GWL_STYLE)
Else
lStyle = GetWindowLong(m_hListView, GWL_STYLE)
End If
LVHasVertical = (lStyle And WS_VSCROLL) <> 0
End Function