Microsoft KB Archive/49737
INF: PM Sample Program That Demonstrates Superclassing PSS ID Number: Q49737 Article last modified on 09-09-1991 PSS database name: P_PresMan
There is a sample application in the Software/Data Library named PMSPRCLS that demonstrates the idea of “superclassing.” Superclassing provides the same capabilities as does subclassing, however, it can be much more convenient to use and produces smaller code if there are multiple controls to be altered in the same fashion. Superclassing is also capable of trapping the messages sent to the window by WinCreateWindow() before it has returned a window handle to use for subclassing.
PMSPRCLS can be found in the Software/Data Library by searching on the keyword PMSPRCLS, the Q number of this article, or S12427. PMSPRCLS was archived using the PKware file-compression utility.
The idea behind superclassing is to create an entirely new class that uses the standard control window procedure, instead of the default window procedure. This lets programmers process the messages that they want to and pass the others along, having them handled properly for this type of control.
This is done by querying everything about the control and making a new class with the same parameters, except with the new class name and window procedure substituted. When the window procedure is called, just handle the desired messages, and pass the others on to the standard control window procedure that were queried on earlier.
Registering a new class this way lets the programmer create superclassed controls via the .RC file or WinCreateWindow() without any further trouble. This can save a number of calls to WinSubclassWindow() if multiple controls are to be modified in the same manner.
In the PMSPRCLS example, a new type of control called “SuperEdit” is created, which is identical to entryfield controls, except that it expands its text limit to allow strings longer than 32 characters to be initialized from the RC file. This version sets the limit to the length of the string, however, other values can be used.
Search for the string “Super” in the .C and .RC files to see the affected areas of the code.
Copyright Microsoft Corporation 1991.