|
ivccav老师您好!我根据您的代码,想把“鼠标显示所在行列”改为“双击获取值”,代码如下:
Public p1, p2
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 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
End Type
Private Const LVM_FIRST = &H1000
Private Const LVM_SUBITEMHITTEST = (LVM_FIRST + 57)
Private Sub ListView1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As stdole.OLE_XPOS_PIXELS, ByVal y As stdole.OLE_YPOS_PIXELS)
p1 = x: p2 = y
Debug.Print p1 & "!" & p2
End Sub
Private Sub ListView1_MMove(ByVal x As stdole.OLE_XPOS_PIXELS, ByVal y As stdole.OLE_YPOS_PIXELS)
Dim intRow%, intCol%
Dim lvhti As LVHITTESTINFO
lvhti.pt.x = x: lvhti.pt.y = y
If SendMessage(ListView1.hwnd, LVM_SUBITEMHITTEST, 0, lvhti) <> -1 Then
intRow = lvhti.iItem + 1
intCol = lvhti.iSubItem + 1
If intCol > 1 Then
Debug.Print 1
Else
Debug.Print 1
End If
End If
End Sub
Private Sub ListView1_DblClick()
ListView1_MMove x, y
End Sub
双击无效,好像P1,P2获取不到X,Y的值,请问是什么原因呢,应该怎么改,谢谢! |
|