mouse over graphical objects event?
-
Hi all, I draw a rectangle. Now I want, that rectangle changes the color, when mouse over it. I want to have an event when mouse is over rectangle, and NOT track all mouse moves. Is it possible? I just can't find a good way to do it? Thanks a lot, Boni
-
Hi all, I draw a rectangle. Now I want, that rectangle changes the color, when mouse over it. I want to have an event when mouse is over rectangle, and NOT track all mouse moves. Is it possible? I just can't find a good way to do it? Thanks a lot, Boni
Sure, but you will have to track the mouse movement, if you think about it, if you didn't track the mouse movement it wouldn't be very effective. Assuming your class has a
Rectangle
object (i.e.,rect
in the example), within yourMouseMove
eventhandler you could say:If rect.Contains(Cursor.Position) Then
'change your color here, you are inside the rectangle
End If- Nick Parker
My Blog | My Articles -
Sure, but you will have to track the mouse movement, if you think about it, if you didn't track the mouse movement it wouldn't be very effective. Assuming your class has a
Rectangle
object (i.e.,rect
in the example), within yourMouseMove
eventhandler you could say:If rect.Contains(Cursor.Position) Then
'change your color here, you are inside the rectangle
End If- Nick Parker
My Blog | My ArticlesHi Nick, thank you so much for the answer. But can't windows notify me with an event, when the mouse is over my rectangle? (I could imagine to register the rectangles "contain"-method somewhere(?)) I fear, that if track mouse for all of my 1000 objects (not only rectangles but even more complicated figures) for each move this will slow down the PC very much. Thanks for your time, boni