1. Subclass
Changes the nature of an existing window instance: Message Processing and other instance attributes.
In the SDK Programming scope, subclass is to change the window functions of a window instance (through getwindowlong () and setwindowlong ()), to subclass a window, you must compile a new window function for a window instance. Its operations are performed at the instance level.
In MFC, subclasses are different: All MFC windows have the same window function, and the window function searches for window instances based on the window handle, you can map messages to the message processing functions of the window class. In order to use the message ing mechanism of MFC, it is not appropriate to change the window function (name). MFC also encapsulates subclass in the subclasswindow () function. However, the nature of subclass has not changed: affects window messages and their processing at the instance level. Example:
Class B: public
{
......
}
A;
B;
Hwnd HA = A. getsafehwnd ();
B. subclasswindow (HA); # Of course, A and B are not necessarily inherited.
Note: Before the quilt-type window is destroyed, the window anti-subclass must be executed:
B. unsubclasswindow ();
2 superclass
Window superclass change the features of window classes at the wndclass or wndclassex level..
Procedure: Obtain an existing window class, set the window class, and register the window class.
Example:
Wndclassex WC;
WC. cbsize = sizeof (WC); // Windows version check, not related to window features
Getclassinfoex (hinst, "xxxxxx", & WC );
// Hinst-defines the handle of the module of the window class xxxxxx. For example, if it is a system-defined window class (such as edit and button), hinst = NULL ..
WC. lpszclassname = "yyyyyyy"; // The Name Of The window class must be changed.
WC. hbrbackground = createsolidbrush (RGB (0, 0.0); // change the background brush
WC. lpfnwndproc = newwndproc; // change the Window Function
......
Registerclassex (& WC); // register a new window class
// Use the window class
......
: Createwindow (_ T ("yyyyyyyy ",......);
Therefore, superclassization can only change the features of the window created by itself, but cannot be used for Windows-created windows (for example, buttons on the dialog box cannot be superclassized ). Subclass is at the instance level. As long as the window instance can be obtained, it can be subclass. This is the only advantage of subclass for superclass. In addition, all sub-classes that can be implemented by superclass, but they are troublesome to use.
3. Summary
(0) Modify Window Process functions by subclass, and modify window classes by superclass (new window class name)
(1) subclass is at the window instance level, and superclass are at the wndclass level.
(2) superclassization can accomplish more complex functions than subclass. In the SDK category, subclass can be considered as a subset of superclassization.
(3) subclass can only change the nature of the window created after it is created. There is nothing to do with the window creation process (on_create events cannot be intercepted), while superclass can be implemented. superclass cannot be used in Windows, subclass.
4. Miscellaneous
See for reality (2): This section describes windows Windows window, message, subclass, and superclass. Here is an example ..
Conclusion can be drawn.
A) The subclass classname will not change, while the superclass will use the newly registered classname.
B) subclass & superclass describe an action and its implementation methods ..... the main subclass is subclasswindow and subclassdlgitem, while the superclass are registerclassex (& newwindowclass)
C) I feel that there is no need to differentiate these features, so we can implement the functions.