Set a messages handler for a window

Hi
What code should I use to set the message handler for a window. I have two windows and I want to set a separate messages handler for each one of them.
Thanks!
You set the handler (WndProc function) to a window class. If both windows use the same window class, then they will use the same handler. You will need to create two window classes and have one window use one class and have the other window use the other.
Mostly true what shacktar said, but there's a way to "override" the window procedure of any given window. The procedure is called Subclassing. You use SetWindowLongPtr() to provide a new pointer to a new window procedure function and that's it in a nutshell. The new window procedure will take it from there. You can save the old window procedure pointer to ensure default message processing.
OK. I got it. So, I can create a class for each window (at build-time) or SetWindowLongPtr (at run-time).
Thanks
Last edited on
Topic archived. No new replies allowed.