WNDCLASS

Window-Class Data Structure

The WNDCLASS structure contains the class attributes that are registered by the RegisterClass function.

typedef struct tagWNDCLASS {

WORD style;

long (FAR PASCAL *lpfnWndProc)();

int cbClsExtra;

int cbWndExtra;

HANDLE hInstance;

HICON hIcon;

HCURSOR hCursor;

HBRUSH hbrBackground;

LPSTR lpszMenuName;

LPSTR lpszClassName;

} WNDCLASS;

The WNDCLASS structure has the following fields:

Field Description  
style Specifies the class style. These styles can be combined by using the bitwise OR operator. The style field can be any combination of the following values:  
  Value Meaning
  CS_BYTEALIGNCLIENT Aligns a window's client area on the byte boundary (in the x direction).
  CS_BYTEALIGNWINDOW Aligns a window on the byte boundary (in the x direction).
  CS_CLASSDC Gives the window class its own display context (shared by instances).
  CS_DBLCLKS Sends double-click messages to a window.
  Value Meaning
  CS_GLOBALCLASS Specifies that the window class is an application global class. An application global class is created by an application or library and is available to all applications. The class is destroyed when the application or library that created the class terminates; it is essential, therefore, that all windows created with the application global class be closed before this occurs.
  CS_HREDRAW Redraws the entire window if the horizontal size changes.
  CS_NOCLOSE Inhibits the close option on the System menu.
  CS_OWNDC Gives each window instance its own display context. Note that although the CS_OWNDC style is convenient, it must be used with discretion because each display context occupies approximately 800 bytes of memory.
  CS_PARENTDC Gives the parent window's display context to the window class.
  Value Meaning
  CS_SAVEBITS Saves the portion of the screen image that is obscured by a window; Windows uses the saved bitmap to re-create a screen image when the window is removed. Windows displays the bitmap at its original location and does not send WM_PAINT messages to windows which had been obscured by the window if the memory used by the bitmap has not been discarded and if other screen actions have not invalidated the stored image. An application should set this bit only for small windows that are displayed briefly and then removed before much other screen activity takes place. Setting this bit for a window increases the amount of time required to display the window due to the time required to allocate memory to store the bitmap.
  CS_VREDRAW Redraws the entire window if the vertical size changes.
lpfnWndProc Points to the window function.  
cbClsExtra Specifies the number of bytes to allocate following the window-class structure.  
cbWndExtra Specifies the number of bytes to allocate following the window instance. If an application is using the WNDCLASS structure to register a dialog box created with the CLASS directive in the .RC script file, it must set this field to DLGWINDOWEXTRA.  
hInstance Identifies the class module. The hInstance field must be an instance handle and must not be NULL.  
hIcon Identifies the class icon. The hIcon field must be a handle to an icon resource. If hIcon is NULL, the application must draw an icon whenever the user minimizes the application's window.  
hCursor Identifies the class cursor. The hCursor field must be a handle to a cursor resource. If hCursor is NULL, the application must explicitly set the cursor shape whenever the mouse moves into the application's window.  
hbrBackground Identifies the class background brush. The hbrBackground field can be either a handle to the physical brush that is to be used for painting the background, or it can be a color value. If a color value is given, it must be one of the standard system colors listed below, and the value 1 must be added to the chosen color (for example, COLOR_BACKGROUND + 1 specifies the system background color). If a color value is given, it must be converted to one of the following HBRUSH types:  
  COLOR_ACTIVEBORDER
COLOR_ACTIVECAPTION
COLOR_APPWORKSPACE
COLOR_BACKGROUND
COLOR_BTNFACE
COLOR_BTNSHADOW
COLOR_BTNTEXT
COLOR_CAPTIONTEXT
COLOR_GRAYTEXT
COLOR_HIGHLIGHT
COLOR_HIGHLIGHTTEXT
COLOR_INACTIVEBORDER
COLOR_INACTIVECAPTION
COLOR_MENU
COLOR_MENUTEXT
COLOR_SCROLLBAR
COLOR_WINDOW
COLOR_WINDOWFRAME
COLOR_WINDOWTEXT
 
  When hbrBackground is NULL, the application must paint its own background whenever it is requested to paint in its client area. The application can determine when the background needs painting by processing the WM_ERASEBKGND message or by testing the fErase field of the PAINTSTRUCT structure filled by the BeginPaint function.  
lpszMenuName Points to a null-terminated character string that specifies the resource name of the class menu (as the name appears in the resource file). If an integer is used to identify the menu, the MAKEINTRESOURCE macro can be used. If the lpszMenuName field is NULL, windows belonging to this class have no default menu.  
lpszClassName Points to a null-terminated character string that specifies the name of the window class.