Coordinates related to form and not screen

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

Hi,

I have a form which has a panel which has a picturebox inside of that.
When a user clicks on the picture, it zooms by x2. The panel has
autoscroll set to true, so when the image is larger then the panel, I
can scroll to a different part of it. What I'm looking to do is when a
user clicks on the image,the point at which he/she clicks is then
centered in the panel by using autoscrollposition. My problem is that
I'm not sure of how to get x,y of the mouse position related to the
panel and not the screen. So either

A.) How can I get the x/y of the mouseposition related to the panel
only or
B.) How can I get the position of the upper lefthand corner of the
panel x/y related to the screen then subtract that or
C.) I'm just a noob

Thanks in advance
Rob
 
Hi,

The form and all controls have the PointToClient method returns
the converted coordinates. Here is an example for a form

Dim pt As Point = Me.PointToClient(Cursor.Position)


Ken
 
Back
Top