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 LB_ITEMFROMPOINT = &H1A9
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim P As Long
Dim XPosition As Long, YPosition As Long
XPosition = CLng(X / Screen.TwipsPerPixelX)
YPosition = CLng(Y / Screen.TwipsPerPixelY)
P = SendMessage(List1.hWnd, LB_ITEMFROMPOINT, 0, ByVal ((YPosition * 65536) + XPosition))
List1.ListIndex = P
End Sub
Dim txtheight%
Private Sub Form_Load()
For i = 1 To 30
List1.AddItem i
Next
Picture1.Visible = False
Picture1.FontName = List1.FontName
Picture1.FontSize = List1.FontSize
txtheight = Picture1.TextHeight("|")
End Sub
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim tmp&
If Button = vbRightButton Then
tmp = Int(Y / txtheight) + List1.TopIndex
If tmp < List1.ListCount Then
List1.ListIndex = tmp
Else: List1.ListIndex = -1
End If
End If
End Sub
Сейчас этот форум просматривают: Google-бот, Yandex-бот и гости: 152