views:

51

answers:

2

Hi.

  • I have a panel and have added a PictureBox to it.
  • I have added mouse_click listeners to both the panel and the picturebox.
  • When they are clicked i create a messagebox which tells me the mouse position.

Problem:

  • When i click the panel, i get the mouse position i want.
  • When i click the pictureBox, i get the current position in that picturebox.

What i want:

  • I want both of the controls to get the current mouseposition on the form.
  • I can also go with getting the current mouseposition of the panel, since it is overlaying the form.

Does anybody know how i can do this? I've googled around for this, but can't seem to find anything about it.

Thank you in advance.

+4  A: 

see PointToScreen and PointToClient methods on the control.

eschneider
I'll look into that. Thank you :)
A: 

If you want the position from the entire form just add the width and height of those items to your point.

Icono123