【发布时间】:2015-02-15 20:56:07
【问题描述】:
我有一个名为 BGImage 的图片框。我希望当用户点击它时,我可以捕捉到鼠标相对于BGImage的位置。
我尝试使用MousePosition,却发现它在屏幕上给出了鼠标位置,而不是在图片框上。
所以我也尝试使用PointToClient:
Dim MousePos As Point = Me.PointToClient(MousePosition)
但这给了我{X=1866,Y=55} 的位置,而我实际上点击了{X=516,Y=284} 附近的图片框。
我认为问题的出现是因为我已经全屏显示了我的程序并将 PictureBox 的位置设置在屏幕的中心 (BGImage.Location = New Point((My.Computer.Screen.WorkingArea.Width / 2) - (1008 / 2), ((My.Computer.Screen.WorkingArea.Height / 2) - (567 / 2))))
我还应该提到 PictureBox 的大小是 1008 × 567 像素,我的屏幕分辨率是 1366 × 768。
有什么方法可以让鼠标位置相对相对于 BGImage 的位置?
【问题讨论】:
标签: vb.net winforms screen-resolution windows-controls