A subclass is a window or set of windows that belong to the same window class, and whose messages are intercepted and processed by another window procedure (or procedures) before being passed to the class window procedure.
To create the subclass, the SetWindowLong function is used to change which window procedure is associated with a particular window, causing Windows to call the new window procedure instead of the previous one. An application must call the CallWindowProc function to pass to the previous window procedure any messages not processed by the new window procedure. This allows Windows to create a chain of window procedures. The application can retrieve the address of the previous window procedure by using the GetWindowLong function before using the SetWindowLong function.
Similarly, the SetClassLong function changes which window procedure is associated with a window class. Any window that is subsequently created with that class will be associated with the replacement window procedure for that class, as will the window whose handle is passed to SetClassLong. Other existing windows that were previously created with the class are not affected, however.
When an application subclasses a window or class of windows, it must export the replacement window procedure in its module-definition file, call the MakeProcInstance function to create the address of the procedure, and pass the address to the SetWindowLong or SetClassLong function. For more information about module-definition files, see the Microsoft Windows Guide to Programming.