Results 1 to 6 of 6

Thread: Tricky little problem. I'm sure the solution is easy though

  1. #1

    Thread Starter
    Fanatic Member The_Grudge's Avatar
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    836

    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.

  2. #2

    Thread Starter
    Fanatic Member The_Grudge's Avatar
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    836

    Unhappy Re: Tricky little problem. I'm sure the solution is easy though

    Ba ba ba ba BUMP.

  3. #3
    Fanatic Member
    Join Date
    Jan 2005
    Location
    In front of this pc.
    Posts
    580

    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:
    1. Private Type POINTAPI
    2.     x As Long
    3.     Y As Long
    4. End Type
    5.  
    6. Private Type LVHITTESTINFO
    7.    pt As POINTAPI
    8.    flags As Long
    9.    iItem As Long
    10.    iSubItem As Long
    11. End Type
    12.  
    13. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    14.     (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wparam As Long,  _
    15.     lParam As Any) As Long
    16.  
    17. Private Sub listview_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
    18.     Dim lvhti As LVHITTESTINFO
    19.     Dim lItemIndex As Long
    20.    
    21.     lvhti.pt.x = x / Screen.TwipsPerPixelX
    22.     lvhti.pt.Y = Y / Screen.TwipsPerPixelY
    23.     lItemIndex = SendMessage(listview.hwnd, LVM_HITTEST, 0, lvhti) + 1
    24.    
    25.     If (lItemIndex >= 1) And (lItemIndex <= listview.ListItems.Count) Then
    26.         listview.ToolTipText = "whatever you want to tip to be"
    27.     Else
    28.         listview.ToolTipText = ""
    29.     End If
    30. End Sub

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  5. #5
    Addicted Member makster246's Avatar
    Join Date
    Dec 2004
    Location
    nottingham
    Posts
    187

    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??

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width