Link to home
Start Free TrialLog in
Avatar of Mike Eghtebas
Mike EghtebasFlag for United States of America

asked on

ToolTipText Update of ListView Control...MouseMove Event

In a vb 6 form, I am trying to addopt following code to update ToolTipText content in MouseMove event.  My list view control (lvWs) has 4 columns but wide-enough to show only two.  The remaining two columns aren't very important nevertheless, I want user to see it when the mouse is moved on certain list item.

Following code is used to do, in a way, similar thing with a list box.  Depending what item is right-clicked on, it opens a popup menu specific to that item.  

Private Sub lstAllPagesWith_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)

    Dim typPoint As POINTAPI, lngSel As Long, intTemp As Integer
    If Button = vbRightButton Then
    'typPoint.X = X \ Screen.TwipsPerPixelX
    typPoint.y = y \ Screen.TwipsPerPixelY
    Call ClientToScreen(lstAllPagesWith.hWnd, typPoint)
    lngSel = LBItemFromPt(lstAllPagesWith.hWnd, typPoint.x, typPoint.y, False)
    If lngSel > -1 Then
    lstAllPagesWith.Selected(lngSel) = True
    strFlag = Left(lstAllPagesWith.List(lngSel), 3)
    Select Case strFlag
        Case "Pag"
            Call ShowPopup("Pag", y) ', True, True, True, False)
        Case "Col"
            Call ShowPopup("Col", y) ', True, True, True, True)
        Case "Row"
            Call ShowPopup("Row", y) ', True, True, False, False)
    End Select

    End If
    End If
   
    ApplyUndo False
    FlagToApplyFormat

End Sub

Now, I want to use this sample to code it for mouse move event such that it will detect what list item it is on.  Then I suppose, it will easy to build a string of the first subItem plus last two to update ToolTipText property.

Any other solution that works also is fine with me.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of dbrckovi
dbrckovi
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I forgot to mention: You have to set lvWs's FullRowSelect property to True.

When it's set to false, then HitTest works only on main items (that's why I used 100 in Set Item = lvWs.HitTest(100, y)).
But when first column was not visible, it didn't work.

Setting FullRowSelect property to True, eliminates this problem, so now you can use      Set Item = lvWs.HitTest(x, y)        if you want.
Avatar of Mike Eghtebas

ASKER

Re:> I think it should work immediately...

You were right.  Thank you for this fantastic solusion.

mike