Catching a message
-
How could I be able to catch a message that was sent to an application which I have its handle(Window handle)? thanks for help.
Override
WndProc
. Stability. What an interesting concept. -- Chris Maunder -
Override
WndProc
. Stability. What an interesting concept. -- Chris Maunder -
Or if you want a more dynamic solution look up the
IMessageFilter
interface. Message filters can be added and removed from windows forms application at runtime.Note that this is better for handling application messages, not specific messages for a control. For the latter, you should override
WndProc
. Using an application filter (IMessageFilter
) can slow down your code drastically if you don't optimize it by keeping in mind that all messages posted to your application will filter through it. Also,IMessageFilter
only catches messages posted to your application pump (a laPostMessage
) while overridingWndProc
catches messages posted or sent (a laPostMessage
orSendMessage
).Microsoft MVP, Visual C# My Articles