Difference Between IMessageFilter and Overriding WndProc

Posted on 2010-01-10
Medium Priority
Last Modified: 2013-12-17
As the title says, what's the difference? Or better perhaps, when would I want to use one over the other?
Question by:käµfm³d   👽
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 26278565
LVL 96

Accepted Solution

Bob Learned earned 1000 total points
ID: 26278600
The primary difference that I see is the the IMessageFilter is an inline filter, where overriding WndProc replaces the entire message processing method.  If you override WndProc, then you need to make sure that you are passing on the correct messages, or you will get unexpected results.  With an IMessageFilter, you can monitor for an do additional processing when messages are received through the filter.
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 1000 total points
ID: 26278729
Also, WndProc will get messages intended for that window/form/control (or possibly some of its children) whereas IMessageFilter gets messages intended for the entire application before it gets dispatched to the window/control/form.  So IMessageFilter occurs way earlier in the notification sequence...
LVL 75

Author Closing Comment

by:käµfm³d 👽
ID: 31675225
Wow. I managed to pull two top minds out of the fray. How cool is that?

Seriously, though, thanks guys!

Featured Post

Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question