picturebox + graphics

alien

Member
Joined
Mar 21, 2006
Messages
24
he guyz, i need some help with graphics. am using vb.net 2003 to create an application that draws an ellipse at the point which it has been clicked on a picturebox(am using the click event of the picturebox). however i need another action to be performed once the user clicks on the ellipse. how can i be able to identify that the ellipse has been clicked on and at the same time not to fire the click event of the picturebox?

thanks
 
To see if the elipse has been clicked on there are a few techniques you could use. If you are using an Image to buffer the PictureBox and you are drawing a solid ellipse, you could check the color of the pixel the user clicked on. A better option would be to store the location of the ellipse. You can use a geometric formula to determine if the point clicked is contained within the ellipse (if the ellipse is a circle, a simple distance formula would work).

As to the question of the click event, it sounds like you want to surpress it. To do so you would probably need to inherit the class and override the OnClick method. However, it will probably be better (and easier) to include an if statement inside the handler that only executes under desired circumstances. Instead of using the Click event, you could use the MouseDown or MouseUp events (or a combination of the two) so that you can examine the position of the mouse and decide whether or not to react (or how to react).
 
Back
Top