Windows may be subclassed by replacing the window procedure defined by the window class with another window procedure. This new subclass window procedure typically processes some of the messages routed to it, and then calls the original window procedure to process any other messages. This technique parallels the definition of subclassing given in Object-Oriented Applications.
Presentation Manager implements subclassing by having the application call the WinSubclassWindow() function, specifying the handle of the window to be subclassed and the new subclass window procedure. Note that only the window specified is affected by the WinSubClassWindow() function call; other windows of the same class are not subclassed. Once the call is successfully issued, any messages destined for the original window procedure are automatically routed to the subclass window procedure by Presentation Manager. The object (whether a window or the operating system) from which the message originated is unaware of the subclass window procedure's interference. An example of a subclass window procedure is given in Figure "Subclass Window Procedure".
The subclassing concept enables messages destined for particular windows to be intercepted and the processing resulting from certain messages to be altered. This provides a powerful mechanism that facilitates the creation and use of generic windows (application objects), while retaining the ability for the application to modify the behavior of such windows should the need arise. The use of subclassing enables a newly created window to take on the properties and methods of existing window classes in accordance with the principle of inheritance.
Presentation Manager enables the effect of subclassing a window to be reversed by the application issuing the WinSubclassWindow() call a second time for the same window, specifying the original window procedure. Presentation Manager then routes messages directly to their intended destination. This capability allows windows to be temporarily subclassed to meet changing requirements at different points during application execution.