هل تريد معرفة العنصر الذي تحت مؤشر الفأرة في ListBox

  • طباعة


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_MouseMove(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))

If P < List1.ListCount Then

      List1.ToolTipText = List1.List(P)

End If

End Sub


http://www.arabteam2000-forum.com/