4
Reply

How to tell if mouse pointer is over Ellipse?

Dan

Dan

Mar 10 2011 1:10 PM
6.2k

Hi guys,

I'm trying to work out how I can tell if a user places their mouse pointer over the area of a circle I have on a form. I want to rotate the circle depending on where the user places the mouse.

I know about the 'MouseMove' event & I've been able to track fine if the mouse is moved over a square, as this is pretty simple. However, I can't work out how to do it for a circle!

The way I'd thought to do it was simply to work out the circle's centre location & then anything that was the length of the circle's radius away, I thought would be in the circle. However the ways I've tried of doing this are clearly wrong as they just track if the mouse is over a virtual square whose length is the diameter of the circle - & so return that the mouse is over the circle, when it isn't as the circle obviously doesn't completely fill the square.

I wondered if anyone knew of a way to do this or even if there were a standard command for just such a thing?

I know the basics of working out what a circle's circumference is from its radius or diameter & I know how to work out a circle's area from its radius also. However, I've no idea how to track exactly a given sized circle's area over a form by X & Y location.

Thanks very much indeed,

Dan.


Answers (4)