Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
TitleTrack the ListBox item under the mouse
KeywordsListBox, mouse, over
CategoriesControls, API
 
Thanks to Sergio Perciballi.

Use GetCursorPos to get the mouse position. Use LBItemFromPt to get the item at that position.

 
Private Sub Form_MouseMove(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    'should provide list autodragging
    Dim ret, cp As POINTAPI
    GetCursorPos cp
    ret = LBItemFromPt(List1.hwnd, cp.X, cp.Y, True)
    Form1.Caption = ret & ":" & X & ":" & Y
    List1.ListIndex = ret
End Sub

Private Sub List1_MouseMove(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    Dim ret, cp As POINTAPI
    GetCursorPos cp
    ret = LBItemFromPt(List1.hwnd, cp.X, cp.Y, True)
    Form1.Caption = ret & ":" & X & ":" & Y
    List1.ListIndex = ret
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated