0
我的代码:VB:鼠标点击不起作用
Me.KeyPreview = True
...
Private Sub Form_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseClick
If e.Button = Windows.Forms.MouseButtons.Right Then
MsgBox("Right Mouse clicked.")
End If
End Sub
尝试捕捉鼠标右键点击,但不起作用。
欢迎任何建议。谢谢
这将工作时,鼠标是在窗体的开放部分(意义也没有超过控制,面板或任何其他)。 – Plutonix
如果你在'If'行放置了一个断点,它会被击中吗?当你认为它应该的时候,它可能并不是在'If'块中。或者可能事件没有正确地附加到“Form”。 –
除了Plutonix的评论:您必须使用全局钩子捕获窗体外的鼠标点击。 [这里是一个VB.NET问题](http://stackoverflow.com/questions/2080617/intercepting-mouse-events-using-a-global-hook-stop-an-action-from-happening)包含一些鼠标钩子代码。 –