What Is Superclassing?
Superclassing, also known as class cloning,
allows
us to build upon an existing window class. See Figure 7-1 for an illustration of this technique. The
existing class is
called the base class. This can be any available class defined by the
system or by an application. The base class information, obtained
from its WNDCLASSEX
structure,
is copied into a second
WNDCLASSEX
structure. This second
WNDCLASSEX
structure is the beginning of our
superclass. Before we have a usable superclass, we must do a couple
of things to this new class structure. We must give it a new class
name, a new instance handle, and a new window procedure. Also, we
must register it with the system. After we do this we have a
superclass that we can use to create new specialized windows for our
applications.
Figure 7-1. The superclassing technique
The new window procedure we provide for the superclass defines the
behavior of windows derived from this class. We can also modify
members of the superclass’s’
WNDCLASSEX
structure. For example, the
style
member can be modified to change the
window’s border, or the
hbrBackground
member can be changed to
define the window’s default background color. These
modifications are left to the developer’s discretion.
When the superclassing application terminates, it should remove all superclasses that it created from memory. It does this through a call to ...
Get Subclassing and Hooking with Visual Basic now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.