VB2010 Get Mouse Position On Form

血红的双手。 提交于 2019-12-25 06:58:35

问题


i currently have a form that is not maximized. I have some code in the MouseDown sub that when i click on the form, it will give me a msgbox that has the mouse click position. The problem is that when i move the form and click at the same location, it does not give me the same location. It is giving me the position of the window screen, not the form. Is there a way i can fix this?

Code:

sub MouseDown.......

msgbox Mouseposition.x & ", " & mouseposition.y
end sub

回答1:


If you want client coords use e.X and e.Y:

Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles MyBase.MouseDown
    MessageBox.Show(e.X & ", " & e.Y)
End Sub


来源:https://stackoverflow.com/questions/27426534/vb2010-get-mouse-position-on-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!