click on a picture

Hello,
I'm importing a picture of a cabinet and i was wondering if there was anyway to have different events fire off when a specific location is clicked on the picture.  for example, i have a picture of the cabinet with 5 drawers.  i want to be able to go to a specific drawer if the user double clicks on it.  This is for an inventory project i'm working that i would then get the info from a DB.  I know each picturebox has a doubleclick event, but my understanding of that is its for the entire picturebox.  Am i making sense with my question?  thanks for the help!

kevinmeredithAsked:
Who is Participating?
 
jake072Connect With a Mentor Commented:
No problem:

I would have a form level variable:

Private ptMousePos as Point

Then in your MouseMove event:

    Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
        ptMousePos = New Point(e.X, e.Y)
    End Sub

Now you have a point of where the cursor is...

You can access the X & Y via ptMousePos.X & .Y :)

Let me know if you need further assistance,

Jake
0
 
jake072Commented:
You could trap the location of the mouse in the MouseMove event, and use that in conjunction with the doubleclick to find out where the mouse is...

Jake
0
 
kevinmeredithAuthor Commented:
can you give me an example please jake?  i'm not familiar with MouseMove
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
kevinmeredithAuthor Commented:
thanks Jake.  I will try that.  with the holiday weekend, i might not reward you the points or ask any additional questions for a while.  just to let you know.  thanks!
0
 
ctm5Commented:
Jake's suggestion is the way to go if you don't want to get into subclassing or third-party controls. If you are willing to use a third-party control, there are lots. Google ImageMap and VB.

ctm5
0
 
ctm5Commented:
oops, sorry Jake, didn't know you were still around.

ctm5
0
 
jake072Commented:
ctm5 - no worries!

We're all here to help!

Jake
0
 
ctm5Commented:
Yeah, but I hate stepping one someone's toes!
0
 
kevinmeredithAuthor Commented:
that worked awesome Jake!  thanks alot
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.