Tricky little problem. I'm sure the solution is easy though
On my form there is a listbox full of names. This listbox is setup for OLE drag & drop so the user can drag names from this list.
This morning, I added a feature so that when a persons name is hilighted in the list, the "tooltiptext" pops up with additional information on that person.
The problem is that it doesn't look so good because you need to click a name in the list to make the tooltip show up. Doing so changes the mouseicon to the circle with the bar through it because it thinks your starting OLE drag drop.
I almost need some code that says if the user left-clicks and let's go, display the tool tip text...if they left click and hold, then do OLE drag drop.
I hope that makes sense.
Re: Tricky little problem. I'm sure the solution is easy though
Re: Tricky little problem. I'm sure the solution is easy though
How about a "on hover" kind of thing? This code works with listviews - just, in the MouseMove event, change all instances of "listview" to whatever the name of your listview is.
VB Code:
Private Type POINTAPI
x As Long
Y As Long
End Type
Private Type LVHITTESTINFO
pt As POINTAPI
flags As Long
iItem As Long
iSubItem As Long
End Type
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 Sub listview_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
Dim lvhti As LVHITTESTINFO
Dim lItemIndex As Long
lvhti.pt.x = x / Screen.TwipsPerPixelX
lvhti.pt.Y = Y / Screen.TwipsPerPixelY
lItemIndex = SendMessage(listview.hwnd, LVM_HITTEST, 0, lvhti) + 1
If (lItemIndex >= 1) And (lItemIndex <= listview.ListItems.Count) Then
listview.ToolTipText = "whatever you want to tip to be"
Else
listview.ToolTipText = ""
End If
End Sub
Re: Tricky little problem. I'm sure the solution is easy though
Quote:
Originally Posted by The_Grudge
This morning, I added a feature so that when a persons name is hilighted in the list, the "tooltiptext" pops up with additional information on that person.
My question is where is this additional information coming from? If you have to query a database everytime someone selects something (or even worse, as the mouse simply moves over the item), then you are running the risk of an awful lot of overhead on your database and network connections.
Re: Tricky little problem. I'm sure the solution is easy though
just a quick note, would the mouse up event not work for displaying the tooltiptext??
Re: Tricky little problem. I'm sure the solution is easy though
Quote:
Originally Posted by makster246
just a quick note, would the mouse up event not work for displaying the tooltiptext??
No. That would still require a click. He's trying to avoid having to do that.
Tg