Here is an example of what I mean:-
vbnet Code:
Public Class Form2 Implements IMessageFilter <DebuggerStepThrough()> _ Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) As Boolean Implements System.Windows.Forms.IMessageFilter.PreFilterMessage 'Left mouse button up Dim WM_LBUTTONUP As Integer = &H202 If Me.IsHandleCreated Then If m.HWnd = Me.Handle AndAlso m.Msg = WM_LBUTTONUP Then Return ButtonUpFiltered(m) End If End If Return False End Function Private Function ButtonUpFiltered(ByRef m As Message) As Boolean MsgBox("Click On " + Me.Name) Return False End Function End Class
Single stepping would completely ignore PreMessageFilter but it would step into ButtonUpFiltered if called by PreMessageFilter. That way you can debug the message filter only when certain messages are trapped and if you wish not to debug them at all you can add the DebuggerStepThrough attribute to the ButtonUpFiltered procedure too.




Reply With Quote