问题
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