Function ListRowCalc (lstTemp As Control, ByVal Y As Single, iMinRef
As Integer, TopIndex As Integer) As Integer Dim ItemHeight As Integer ItemHeight =3D SendMessage(lstTemp.hWnd, LB_GETITEMHEIGHT, 0, 0) ListRowCalc =3D min(((Y / screen.TwipsPerPixelY) \ ItemHeight) + TopIndex, iMinRef - 1) End Function Sub lstImpegni_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single) Dim i As Integer ' calcolo la riga su cui ho clickato i =3D ListRowCalc(lstImpegni, Y, (lstImpegni.ListCount), (lstImpegni.TopIndex)) If Button =3D 2 Then lstImpegni.ListIndex=3D i End Sub ' dichiarazioni Public Const LB_GETITEMHEIGHT =3D &H1A1 Declare Function SendMessage Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, ByVal wMsg As Long, _ ByVal wParam As Long, lParam As Any) As Long Function ListRowCalc(lstTemp As Control, ByVal Y As Single, iMinRef As Integer, TopIndex As Integer) As Integer Dim ItemHeight As Integer ItemHeight =3D SendMessage(lstTemp.hwnd, LB_GETITEMHEIGHT, 0, 0) ListRowCalc =3D Min(((Y / Screen.TwipsPerPixelY) \ ItemHeight) + TopIndex, iMinRef - 1) End Function Function Min(v1 As Single, v2 As Single) As Single Min =3D IIf(v1 <=3D v2, v1, v2) End Function |