Namespace WindowsApplication1
Public Partial Class Form1
Inherits Form
Implements IMessageFilter
Public Sub New()
InitializeComponent()
Application.AddMessageFilter(Me)
AddHandler Me.FormClosed, New FormClosedEventHandler(AddressOf Me.Form1_FormClosed)
End Sub
Private Sub Form1_FormClosed(sender As Object, e As FormClosedEventArgs)
Application.RemoveMessageFilter(Me)
End Sub
Public Function PreFilterMessage(ByRef m As Message) As Boolean Implements IMessageFilter.PreFilterMessage
' Filter out WM_NCRBUTTONDOWN/UP/DBLCLK
If m.Msg = &Ha4 OrElse m.Msg = &Ha5 OrElse m.Msg = &Ha6 Then
Return True
End If
' Filter out WM_RBUTTONDOWN/UP/DBLCLK
If m.Msg = &H204 OrElse m.Msg = &H205 OrElse m.Msg = &H206 Then
Return True
End If
Return False
End Function
End Class
End Namespace