Search code examples
winapiwndproc

Difference between WindowProc and CallWindowProc?


What is the difference between WindowProc and CallWindowProc ?

I can imagine when registering a new window class I can specify my own WindowProc for it.
This leaves the question: When and what for do I use CallWindowProc ?


Solution

  • When you subclass a window using SetWindowLong/Ptr(GWL_WNDPROC) to assign a new WindowProc() to the window, the replacement WindowProc() uses CallWindowProc() when it needs to call the window's original WindowProc():

    Subclassing a window

    The preferred way to subclass a window is to use SetWindowSubClass() instead:

    Safer subclassing