Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

i'm over a red circle? mousemove event 1

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
425
IT
i print this little circles on image with:

Code:
For I = 0 To UBound(Route) - 1
        With Route(I)
            Picture1.Circle (.LNG, .LAT), 0.07, vbRed
            Picture1.CurrentY = Picture1.CurrentY + 0.25
            Picture1.Print I & ")" & .Name
        End With
    Next]

Now, with mousemove event how to intercept when cursor is on the red circle, and get .name?
 
 https://files.engineering.com/getfile.aspx?folder=e5c917c3-b8bf-46d4-8214-c29b777a8aed&file=Immagine.jpg
Ok, so you already have a UDT array that contains all the X and Y coordinates of the centre of the circles and the name (just doesn't track the radius, but you know what that is as it seems to remain constant in your example.

So all you really need to do is iterate through that array to see if the coordinates of the mouse pointer lie within that circle (or cheat, and check whether they are within the bounding box of the circle - at the size you are drawing these the difference will be immaterial). If it is, then simply retrieve the name from the array element you are currently examining

Of course you don't want to have to iterate through the array for all mouse moves, because most of the time it won't be over your circle. So step one is to simply check if the colour under the mouse pointer is red or not - and only if it is to iterate through the array
 
tkx Strongm but not for my knoledgment.
 
Code:
[blue]Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim I As Long
    Dim radius As Single
    
    radius = 0.07 [COLOR=green]' no idea what scalemode you are using, this is just a copy of the radius you used in your example code[/color]
    
    If Picture1.Point(X, Y) = vbRed Then [COLOR=green]' Step 1: is pixel under mouse red?[/color]
    
        For I = 0 To UBound(route) - 1 [COLOR=green]' Step 2: iterate through UDT to see which one represents the red pixel we are over[/color]
            With route(I)
                 If X > .lng - radius And X < .lng + radius And Y > .lat - radius And Y < .lat + radius Then [COLOR=green]' This one![/color]
                    Debug.Print .name [COLOR=green]' Recover the name[/color]
                End If
            End With
        Next
    End If
End Sub[/blue]
 
But... the routine draw a direct line from destination.
possible to draw a route line, similar Google maps?

note:
i just have a Google maps key and Bing Map key.
Choice one from this key.
 
That's a very different question, I'd start a new thread for that, if I were you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top