Тема: ListView: в какой колонке был клик

Как определить, в какой колонке ListView был клик?

Re: ListView: в какой колонке был клик

Option Explicit

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

Private Const LVM_SUBITEMHITTEST As Long = 4153

Private Type POINTAPI
    X As Long
    Y As Long
End Type

Private Type LVHITTESTINFO
    pt As POINTAPI
    lngFlags As Long
    lngItem As Long
    lngSubItem As Long
End Type

Private Sub ListView_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, _
                            X ByVal X As stdole.OLE_XPOS_PIXELS, ByVal Y As stdole.OLE_YPOS_PIXELS)
    Dim hti As LVHITTESTINFO
    Dim lngRet As Long
    hti.pt.X = X
    hti.pt.Y = Y
    lngRet = SendMessage(ListView.hwnd, LVM_SUBITEMHITTEST, 0&, hti)
    Debug.Print "Row=" & hti.lngItem,
    Debug.Print "Col=" & hti.lngSubItem
End Sub