Reputation: 4379
I have a .Net Winforms application. I'm trying to add message filtering via IMessageFilter.
The filter gets added correctly and I am intercepting messages. For purposes I am returning false, so all messages should dispatch and processed.
However, once the filter starts intercepting messages, the messages do not get dispatched to normal filtering/processing.
I'm not sure what's going here. Is this the correct way to intercept/filter messages in a Winforms application? I would like to be able to use this filter to examine information about the winforms controls receiving the events.
Here is my sample MessageFilter class:
public class InspectorMessageFilter : IMessageFilter
{
public bool PreFilterMessage(ref Message message)
{
return false;
}
}
Here is the code to instantiate and add the filter:
var filter = new InspectorMessageFilter();
Application.AddMessageFilter(filter);
Upvotes: 0
Views: 231
Reputation: 4379
I changed my Prefilter definition to:
public class InspectorMessageFilter : IMessageFilter
{
public bool IMessageFilter.PreFilterMessage(ref Message message)
{
return false;
}
}
It all works now!
Upvotes: 0