467,074 Members | 895 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,074 developers. It's quick & easy.

Coordinates related to form and not screen

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
Nov 20 '05 #1
  • viewed: 1295
Share:
2 Replies
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
-----------------
"Rob" <hu****@hotmail.com> wrote in message
news:42*************************@posting.google.co m...
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

Nov 20 '05 #2
PointToClient and PointToScreen methods may do what you need !

Regards - OHM
Rob wrote:
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


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Need_help | last post: by
2 posts views Thread by Robin Senior | last post: by
3 posts views Thread by ZorpiedoMan | last post: by
4 posts views Thread by Henry Wu | last post: by
4 posts views Thread by Tomasz Bak | last post: by
9 posts views Thread by pcnerd | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.