wndproc

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

I just wonder if somebody have a scenario when it would be a reasonable good
solution to use the wndproc to catch the windows message that is send.

I know that this is quite rare that you have to use the wndproc but i hope
somebody can make up some scenario.

//Tony
 
Peter Duniho said:
There are lots of specific examples. The general rule is that if you need
to handle a window message that is not already exposed by the API (e.g.
the System.Windows.Forms.Control class doesn't have an equivalent event
that is raised for the message), then you need to override WndProc()
yourself and look for the message.

I have most commonly used this myself when dealing with user-defined
window messages. In one case, I needed a cross-thread signal that could
not be suitable implemented using the usual Invoke()/BeginInvoke()
approach. In another case, the code was dealing with wrapping an
unmanaged API that used a user-defined window message to notify the client
code of something.

The Win32 API itself defines a large number of window messages that are
not exposed by the Forms API. If your program wants to receive and deal
with those messages, it needs to override WndProc().

Pete

Good explained Pete!

//Tony
 
Back
Top