单击图像获取鼠标位置 [英] Get Mouse Location at Click on a Image
本文介绍了单击图像获取鼠标位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我目前如何在图片框中的图像上获得X和Y位置(图像设置为正常)
Hi this is how I currently get the X and Y location on A image in a Picture Box (Image is set To normal)
Dim xmouse as int16
Dim ymouse as int16
Private Sub PBData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PBData.Click
'Take the click point - The location of the Windows - the Location of the Picturebox in the Window.
xmouse = MousePosition.X - Me.Location.X - 313
ymouse = MousePosition.Y - Me.Location.Y - 99
XLOC.Text = xmouse
Yloc.Text = ymouse
End Sub
想知道是否有更好的方法吗?
基本上我用它来获得较大图像中单击的子图像
并且仅显示其裁剪版本并显示附加值.
and wanted to know if there is a better way to get it?
Basically I used it the get the Sub Image Clicked on in the Larger Image
and Displays just a cropped version of it and displays a attached value.
推荐答案
U可以改用它吗?
Dim xmouse as int16
昏暗的ymouse作为int16
Can U use This instead
Dim xmouse as int16
Dim ymouse as int16
Private Sub PBData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mouse.Click
xmouse = e.X - Me.Location.X - 313
ymouse = e.Y- Me.Location.Y - 99
XLOC.Text = xmouse
Yloc.Text = ymouse
End Sub
U可以解释为什么U使用313和99相减吗??
:cool :: cool:
Can U explain Why are U using 313 and 99 to be subtracted???
:cool::cool:
O是我的PicureBox的起点已与我的表单相对(可以使用位置,并且可以减去X和Y)
PBData的X = 313
YData的Y = 99
O that is the start point of my PicureBox Compaired to my Form (Location can be use and X and Y subtracted)
PBData''s X= 313
YData''s Y= 99
这篇关于单击图像获取鼠标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文