หน้าเว็บ

วันพุธที่ 8 มิถุนายน พ.ศ. 2554

List Mouse Movement [ VB6 ]


Option Explicit

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

Const LB_ITEMFROMPOINT = &H1A9

Function MAKELPARAM(ByVal X As Integer, ByVal Y As Integer) As Long
    MAKELPARAM = CInt(Y) * (2 ^ 16) Or CInt(X)
End Function

Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim CoordX As Long, CoordY As Long, Coord As Long, FPoint As Long
    Dim txt As String
   
    CoordX = X \ Screen.TwipsPerPixelX
    CoordY = Y \ Screen.TwipsPerPixelY
    Coord = MAKELPARAM(CInt(CoordX), CInt(CoordY))
    FPoint = SendMessage(List1.hWnd, LB_ITEMFROMPOINT, 0, ByVal Coord)
   
    If FPoint <= List1.ListCount - 1 Then
        txt = List1.List(FPoint)
        Select Case txt
            Case List1.List(0)
          Text1.Text = "ICheer_No0M"
            Case List1.List(1)
          Text1.Text = "bla bla bla bla" 
            Case List1.List(2)
          Text1.Text = "bla bla bla bla"

        End Select
       
    End If
       
End Sub

ไม่มีความคิดเห็น:

แสดงความคิดเห็น