A window class is a set of attributes that defines how a window looks and behaves. Before an application can create and use a window, a window class must have been created and registered for that window. An application registers a class by filling a WNDCLASS structure and passing a pointer to the structure to the RegisterClass function. Any number of window classes can be registered. Once a class has been registered, Windows lets the application create any number of windows belonging to that class. The registered class remains available until it is deleted or the application closes.
Although a complete window class consists of many elements, Windows requires only that an application supply a class name, the address of the window proce-dure that will process all messages sent to windows belonging to this class, and an instance handle identifying the application that registered the class. The other elements of the window class define default attributes for windows of the class, such as the shape of the cursor and the content of the menu for the window.
There are three types of window classes: system global classes, application global classes, and application local classes. These types differ in scope and in when and how they are created and destroyed.
Windows creates system global classes when it starts. These classes are available for use by all applications at all times. Because Windows creates system global classes on behalf of all applications, an application cannot create or destroy any of these classes. System global classes include edit-control and list-box control classes.
An application or (more likely) a dynamic-link library (DLL) creates an application global class by specifying the CS_GLOBALCLASS style for the class. Once created, it is globally available to all applications within the system. Typically, a DLL creates an application global class so that applications that call the DLL can use the class. Windows destroys an application global class when the application that created it closes or the DLL that created it is unloaded. For this reason, it is essential that all applications destroy all windows using that class before the application that created the class closes or the DLL that created the class is unloaded. Use the UnregisterClass function to remove an application global class and free the storage associated with it.
An application local class is any window class created by an application for its exclusive use. This is the more common type of class created by an application. Use the UnregisterClass function to remove an application local class and free the storage associated with it.