以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]怎么获得鼠标点击位置的信息?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=98930)

--  作者:新福星
--  发布时间:2017/4/9 17:24:00
--  [求助]怎么获得鼠标点击位置的信息?
一个窗口加有一张图片。
如何在点击图片时,获得点击位置数据?谢谢

--  作者:有点色
--  发布时间:2017/4/9 20:51:00
--  

1、去编写mousedown事件获取。

 

2、也可以直接获取鼠标的当前位置来获取。


--  作者:新福星
--  发布时间:2017/4/10 4:31:00
--  
用哪些具体方法?语句?
--  作者:有点色
--  发布时间:2017/4/10 8:28:00
--  

 如果是mousedown,直接获取e.x和e.y即可。

 

 如果是当前鼠标,这样写

 

Dim x As Integer = System.Windows.Forms.Cursor.Current.Position.X
Dim y As Integer = System.Windows.Forms.Cursor.Current.Position.Y

 

 如果是窗口的相对位置,这样写

 

Dim point As Point = Forms("窗口1").Panel.PointToScreen(System.Windows.Forms.Cursor.Current.Position)
msgbox(point.x & " " & point.y)