在WINFORM应用程序中,目前已知两种方法。
1 自定义一个菜单对象,内容空,SIZE定义为(0,0)。然后绑定到相应的控件上去。
Dim spdMenu As Windows.Forms.ContextMenuStrip''dim a menu
spdMenu = New Windows.Forms.ContextMenuStrip''create
spdMenu.ClientSize = New Size(0, 0)''no size
sprShow.ContextMenuStrip = spdMenu''banding to tartage contral
2使窗体实现IMessageFilter接口,然后在实现方法中排除右击的响应。在整个WINDORM中右击事件将不被响应。
Public Class winfrm
Implements IMessageFilter
Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) As Boolean Implements System.Windows.Forms.IMessageFilter.PreFilterMessage
If m.Msg >= 516 AndAlso m.Msg <= 517 Then
Return True
End If
Return False
End Function
End Class