dcsimg
Results 1 to 6 of 6

Thread: CTooltip CLASS multiline tool tip

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Italy-Napoli
    Posts
    1,800

    CTooltip CLASS multiline tool tip

    But in this code wat is the column and rows value?

    If i have understand the row value is:lItemIndex = SendMessage(Me.ListView1.hwnd, LVM_HITTEST, 0, lvhti) + 1..

    Code:
    Private Sub ListView1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
        If Me.ListView1.ListItems.Count > 0 Then
    
            Dim lvhti As LVHITTESTINFO
            Dim lItemIndex As Long, m_lCurItemIndex As Long
    
            lvhti.pt.X = X / Screen.TwipsPerPixelX
            lvhti.pt.Y = Y / Screen.TwipsPerPixelY
            lItemIndex = SendMessage(Me.ListView1.hwnd, LVM_HITTEST, 0, lvhti) + 1
    
            If m_lCurItemIndex <> lItemIndex Then
                m_lCurItemIndex = lItemIndex
                If m_lCurItemIndex = 0 Then   ' no item under the mouse pointer
                    TT.Destroy
                Else
                    TT.Title = "Multiline tooltip"
                    TT.TipText = Me.ListView1.ListItems(m_lCurItemIndex).Text
                    TT.Create Me.ListView1.hwnd
                End If
            End If
    
        End If
    
    End Sub

  2. #2
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    4,843

    Re: CTooltip CLASS multiline tool tip

    Say Luca,

    I'm not sure how to politely ask this. If you don't mind, could you please just outline what you're trying to do? Also, please specify which version of the ListView you're using (6.0 or 5.0).

    Thanks,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Italy-Napoli
    Posts
    1,800

    Re: CTooltip CLASS multiline tool tip

    Quote Originally Posted by Elroy View Post
    Say Luca,

    I'm not sure how to politely ask this. If you don't mind, could you please just outline what you're trying to do? Also, please specify which version of the ListView you're using (6.0 or 5.0).

    Thanks,
    Elroy
    listview 6.0

    and which column number is....
    Last edited by luca90; Dec 8th, 2018 at 02:07 PM.

  4. #4
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    4,843

    Re: CTooltip CLASS multiline tool tip

    Code:
    
    Option Explicit
    '
    Private Type POINTAPI
        X As Long
        Y As Long
    End Type
    '
    Private Type LVHITTESTINFO
        pt As POINTAPI
        lFlags As Long
        lItem As Long
        lSubItem As Long
    End Type
    '
    Private Const LVM_FIRST              As Long = &H1000&
    Private Const LVM_GETNEXTITEM        As Long = (LVM_FIRST + 12&)
    Private Const LVM_HITTEST            As Long = (LVM_FIRST + 18&)
    Private Const LVM_SETITEMSTATE       As Long = (LVM_FIRST + 43&)
    Private Const LVM_SUBITEMHITTEST     As Long = (LVM_FIRST + 57&)
    '
    Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
    '
    
    Private Sub ListViewItemAndSubHitTest(lvw As ListView, X As Single, Y As Single, LvwHitInfo As LVHITTESTINFO)
        ' x and y are in twips. Convert them to pixels for the API call.
        ' The LvwHitInfo is actually returned with the lFlags, lItem, & lSubItem filled out.
        LvwHitInfo.lFlags = 0
        LvwHitInfo.lItem = 0
        LvwHitInfo.lSubItem = 0
        LvwHitInfo.pt.X = X / Screen.TwipsPerPixelX
        LvwHitInfo.pt.Y = Y / Screen.TwipsPerPixelY
        ' Fill in UDT, and return.
        SendMessage lvw.hWnd, LVM_SUBITEMHITTEST, 0, LvwHitInfo
        LvwHitInfo.lItem = LvwHitInfo.lItem + 1 ' In VB, the items are 1 based and in the API they are 0 based.
    End Sub
    
    
    

    Examine the lItem and lSubItem, and that should do it for you. Specifically, the lSubItem is what I believe you want.

    Also, I patched up the Screen.TwipsPerPixel? from my code, as I use a different approach for that. But using the Screen object should probably work for you.

    Good Luck,
    Elroy

    EDIT1: Also, to pull that together, I just threw it all into a Form1. You may want to put it in a BAS module, and change some of it to Public.

    EDIT2: Also, I typically use it in a MouseUp event. And you must pre-declare the incoming LvwHitInfo, as that's effectively your output variable. I suppose you could make it a function and return that UDT, if you wanted.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Italy-Napoli
    Posts
    1,800

    Re: CTooltip CLASS multiline tool tip

    Quote Originally Posted by Elroy View Post
    Code:
    
    Option Explicit
    '
    Private Type POINTAPI
        X As Long
        Y As Long
    End Type
    '
    Private Type LVHITTESTINFO
        pt As POINTAPI
        lFlags As Long
        lItem As Long
        lSubItem As Long
    End Type
    '
    Private Const LVM_FIRST              As Long = &H1000&
    Private Const LVM_GETNEXTITEM        As Long = (LVM_FIRST + 12&)
    Private Const LVM_HITTEST            As Long = (LVM_FIRST + 18&)
    Private Const LVM_SETITEMSTATE       As Long = (LVM_FIRST + 43&)
    Private Const LVM_SUBITEMHITTEST     As Long = (LVM_FIRST + 57&)
    '
    Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
    '
    
    Private Sub ListViewItemAndSubHitTest(lvw As ListView, X As Single, Y As Single, LvwHitInfo As LVHITTESTINFO)
        ' x and y are in twips. Convert them to pixels for the API call.
        ' The LvwHitInfo is actually returned with the lFlags, lItem, & lSubItem filled out.
        LvwHitInfo.lFlags = 0
        LvwHitInfo.lItem = 0
        LvwHitInfo.lSubItem = 0
        LvwHitInfo.pt.X = X / Screen.TwipsPerPixelX
        LvwHitInfo.pt.Y = Y / Screen.TwipsPerPixelY
        ' Fill in UDT, and return.
        SendMessage lvw.hWnd, LVM_SUBITEMHITTEST, 0, LvwHitInfo
        LvwHitInfo.lItem = LvwHitInfo.lItem + 1 ' In VB, the items are 1 based and in the API they are 0 based.
    End Sub
    
    
    

    Examine the lItem and lSubItem, and that should do it for you. Specifically, the lSubItem is what I believe you want.

    Also, I patched up the Screen.TwipsPerPixel? from my code, as I use a different approach for that. But using the Screen object should probably work for you.

    Good Luck,
    Elroy

    EDIT1: Also, to pull that together, I just threw it all into a Form1. You may want to put it in a BAS module, and change some of it to Public.

    EDIT2: Also, I typically use it in a MouseUp event. And you must pre-declare the incoming LvwHitInfo, as that's effectively your output variable. I suppose you could make it a function and return that UDT, if you wanted.
    WOW!
    TKS!
    Pizza?

    luca90 luca90 is online now
    Thread Starter
    Frenzied Member

    Join Date
    Mar 2005
    Location
    Italy-Napoli
    Posts
    1,797

  6. #6

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width