tumblingdown
Sep 29th, 2000, 02:58 AM
has any body ever used LVM_SUBITEMHITTEST succesfully?
This is what i'm doing...
in a module:
Public 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 Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Const LVM_FIRST = &H1000
Public Const LVM_HITTEST = LVM_FIRST + 18
Public Const LVM_SUBITEMHITTEST = LVM_FIRST + 57
Public Type POINTAPI
X As Long
Y As Long
End Type
Public Type LVHITTESTINFO
pt As POINTAPI
flags As Long
iItem As Long
iSubItem As Long
End Type
in a form that has a listview lvw (10 columns, 20 items):
Private Sub lvw_Click()
Dim lvInfo As LVHITTESTINFO
Dim pt As POINTAPI
lrtrn = GetCursorPos(pt)
lvInfo.pt.X = m_lCurrentX '/ set in the mouse_down sub
lvInfo.pt.Y = m_lCurrentY '/ set in the mouse_down sub
lrtrn = SendMessage(lvw.hwnd, LVM_SUBITEMHITTEST, 0&, lvInfo)
Debug.Print "******CurrentX*****************"
Debug.Print "Return " & lrtrn
Debug.Print "Flags " & lvInfo.flags
Debug.Print "Item " & lvInfo.iItem
Debug.Print "SubItem " & lvInfo.iSubItem
lvInfo.pt.X = pt.X
lvInfo.pt.Y = pt.Y
lrtrn = SendMessage(lvw.hwnd, LVM_SUBITEMHITTEST, 0&, lvInfo)
Debug.Print "******GetCursorPos******"
Debug.Print "Return " & lrtrn
Debug.Print "F " & lvInfo.flags
Debug.Print "I " & lvInfo.iItem
Debug.Print "SI " & lvInfo.iSubItem
Debug.Print "***************************************"
end sub
Wether i use LVM_HITTEST OR LVM_SUBITEMHITTEST i cannot get anything other than -1 back on the return (and iItem and iSubItem come back with all sorts of weird and wonderfull!)
Has anyone done this? Anyone see anything obvious that my tired eyes can't? help!!
andy.
p.s. The reason i make the call twice, is because i'm not sure which pointapi the hit test is expecting (i.e. screen or client window.)
This is what i'm doing...
in a module:
Public 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 Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Const LVM_FIRST = &H1000
Public Const LVM_HITTEST = LVM_FIRST + 18
Public Const LVM_SUBITEMHITTEST = LVM_FIRST + 57
Public Type POINTAPI
X As Long
Y As Long
End Type
Public Type LVHITTESTINFO
pt As POINTAPI
flags As Long
iItem As Long
iSubItem As Long
End Type
in a form that has a listview lvw (10 columns, 20 items):
Private Sub lvw_Click()
Dim lvInfo As LVHITTESTINFO
Dim pt As POINTAPI
lrtrn = GetCursorPos(pt)
lvInfo.pt.X = m_lCurrentX '/ set in the mouse_down sub
lvInfo.pt.Y = m_lCurrentY '/ set in the mouse_down sub
lrtrn = SendMessage(lvw.hwnd, LVM_SUBITEMHITTEST, 0&, lvInfo)
Debug.Print "******CurrentX*****************"
Debug.Print "Return " & lrtrn
Debug.Print "Flags " & lvInfo.flags
Debug.Print "Item " & lvInfo.iItem
Debug.Print "SubItem " & lvInfo.iSubItem
lvInfo.pt.X = pt.X
lvInfo.pt.Y = pt.Y
lrtrn = SendMessage(lvw.hwnd, LVM_SUBITEMHITTEST, 0&, lvInfo)
Debug.Print "******GetCursorPos******"
Debug.Print "Return " & lrtrn
Debug.Print "F " & lvInfo.flags
Debug.Print "I " & lvInfo.iItem
Debug.Print "SI " & lvInfo.iSubItem
Debug.Print "***************************************"
end sub
Wether i use LVM_HITTEST OR LVM_SUBITEMHITTEST i cannot get anything other than -1 back on the return (and iItem and iSubItem come back with all sorts of weird and wonderfull!)
Has anyone done this? Anyone see anything obvious that my tired eyes can't? help!!
andy.
p.s. The reason i make the call twice, is because i'm not sure which pointapi the hit test is expecting (i.e. screen or client window.)