[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
Solved

# Tracking the mouse in a list box

Posted on 2004-10-27
Medium Priority
207 Views
I'd like to be able to set the tooltip of a list box based on the entry the mouse is over a list box. Can anyone tell me how this can be accomplished ?

Thanks !
0
Question by:levinlll
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2

LVL 86

Accepted Solution

Mike Tomlinson earned 500 total points
ID: 12426997
Option Explicit

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Long) As Long

Dim i As Integer

For i = 1 To 10
Next
End Sub

Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim idx As Integer
idx = ListRowCalc(List1, Y)
List1.ToolTipText = List1.List(idx)
End Sub

Private Function ListRowCalc(lstTemp As Control, ByVal Y As Single) As Integer
Const LB_GETITEMHEIGHT = &H1A1

Dim ItemHeight As Integer
ItemHeight = SendMessage(lstTemp.hWnd, LB_GETITEMHEIGHT, 0, 0)
ListRowCalc = min(((Y / Screen.TwipsPerPixelY) \ ItemHeight) + _
lstTemp.TopIndex, lstTemp.ListCount - 1)
End Function

Private Function min(X As Integer, Y As Integer) As Integer
If X > Y Then min = Y Else min = X
End Function
0

LVL 76

Expert Comment

ID: 12427006
ListBox1.Tooltip = "My tooltip"
This seems too simple, so I may have misunderstood
0

LVL 76

Expert Comment

ID: 12427026
Yes. It was too simple. I had misunderstood.
0

LVL 8

Expert Comment

ID: 12430432
Private Sub List1_MouseMove()
List1.ToolTip = "ToolTip Text here"
End Sub
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
###### Suggested Courses
Course of the Month13 days, 16 hours left to enroll