开发者

Calculating Cursor Position in c#

开发者 https://www.devze.com 2023-02-05 23:09 出处:网络
Hi All I have a Form with a panel in it. I want to move an image according to t开发者_如何学Gohe cursor position.

Hi All I have a Form with a panel in it. I want to move an image according to t开发者_如何学Gohe cursor position. I have a mouse over function, but how do i do the calculation right ? since the cursor position is from the monitor and the picturebox is from the panel


You can use Control.PointToClient method to convert screen coordinates to the local ones. If you follow the MSDN link there's a good example that shows how to do that.

Point localCoordinates = myPictureBox.PointToClient(mouseScreenCoordinates);
0

精彩评论

暂无评论...
验证码 换一张
取 消