Difference Between IMessageFilter and Overriding WndProc

As the title says, what's the difference? Or better perhaps, when would I want to use one over the other?
LVL 75
käµfm³d   👽Asked:
Who is Participating?
Bob LearnedConnect With a Mentor Commented:
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.
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
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...
käµfm³d 👽Author Commented:
Wow. I managed to pull two top minds out of the fray. How cool is that?

Seriously, though, thanks guys!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.