Catching Windows messages
I needed to capture mouse clicks before my windows app got a hold of them. Seeing that the Form class has a PreProcessMessage method I thought I was all set. As the documentation stated:
Preprocesses input messages within the message loop before they are dispatched.
Perfect! I'll grab my mouse input as needed and then let it pass on to my application for normal processing.
No go. I overrode the method and was clicking and moving all over the place and never got a single message. I did a bit of googling and found out that PreProcessMessage is only for keyboard messages. I don't know about you, but I consider a mouse as an "input" device. Lesson learned (and I reported the documentation issue to Microsoft).
Solution? IMessageFilter and Application.AddMessageFilter. So easy... :)