Since you know where the lines start and end you can determine if the mouse is over one or not by doing the maths...
It might be not quite be what you were hoping for but it works.Code:Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim sX As Long, eX As Long, sY As Long, eY As Long Dim Ln As Line, Over As Boolean, Grad As Single For Each Ln In Line1 Over = False With Ln 'first check if the mouse is in the bounds of the lines rectangle If .X1 < .X2 Then sX = .X1: eX = .X2 Else sX = .X2: eX = .X1 If X >= sX Then If X <= eX Then If .Y1 < .Y2 Then sY = .Y1: eY = .Y2 Else sY = .Y2: eY = .Y1 If Y >= sY Then If Y <= eY Then 'if so check if the mouse is near the line If eX <> sX Then 'to avoid div 0 Grad = (eY - sY) / (eX - sX) If Abs((X - sX) * Grad - (Y - sY)) <= 45 Then Over = True '<= 45 assumes a scalemode of twips at 15/pixel Else Over = True End If End If End If End If End If End With If Over = True Then If Ln.BorderWidth <> 3 Then Ln.BorderWidth = 3 Else If Ln.BorderWidth <> 1 Then Ln.BorderWidth = 1 End If Next Ln End Sub




Reply With Quote