typedef struct tagWNDCLASS { /* wc */
UINT style;
WNDPROC lpfnWndProc;
int cbClsExtra;
int cbWndExtra;
HANDLE hInstance;
HICON hIcon;
HCURSOR hCursor;
HBRUSH hbrBackground;
LPCTSTR lpszMenuName;
LPCTSTR lpszClassName;
} WNDCLASS;
The WNDCLASS structure contains the class attributes that are registered by the RegisterClass function.
style
Specifies the class style. These styles can be combined by using the bitwise OR operator. This can be any combination of the following values:
Value | Meaning |
CS_BYTEALIGNCLIENT | Aligns the client area of a window on the byte boundary (in the x direction). |
CS_BYTEALIGNWINDOW | Aligns a window on the byte boundary (in the x direction). This flag should be set by applications that perform bitmap operations in windows by using the BitBlt function. |
CS_CLASSDC | Gives the window class its own display context (shared by instances). |
CS_DBLCLKS | Sends double-click messages to a window. |
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 exits; 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 display context of the parent window to the window class. |
CS_SAVEBITS | Specifies that the system should try to save the screen image behind a window created from this window class as a bitmap. Later, when the window is removed, the system uses the bitmap to quickly restore the screen image. This style is useful for small windows that are displayed briefly and then removed before much other screen activity takes place (for example, menus or dialog boxes). This style increases the time required to display the window since the system must first allocate memory to store the bitmap. |
CS_VREDRAW | Redraws the entire window if the vertical size changes. |
lpfnWndProc
Points to the window procedure. For more information, see the description of the WindowProc callback function.
cbClsExtra
Specifies the number of extra bytes to allocate following the window-class structure.
cbWndExtra
Specifies the number of extra bytes to allocate following the window instance. If an application uses the WNDCLASS structure to register a dialog box created with the CLASS directive in the resource file, it must set this member to DLGWINDOWEXTRA.
hInstance
Identifies the instance that the window procedure of this class is within.
hIcon
Identifies the class icon. This member must be a handle to an icon resource. If this member is NULL, the application must draw an icon whenever the user minimizes the application's window.
hCursor
Identifies the class cursor. This member must be a handle to a cursor resource. If this member 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. This member 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
The system automatically deletes class background brushes when the class is freed. An application should not delete these brushes because a class may be used by multiple instances of an application.
When this member 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 member 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 this member member is NULL, windows belonging to this class have no default menu.
lpszClassName
Points to a null-terminated string or is an atom that identifies a string. If this parameter is an atom, it must be a global atom created by a previous call to the GlobalAddAtom function. The atom, a 16-bit value, must be placed in the low-order word of lpszClassName; the high-order word must be zero.
The lpszClassName string or atom specifies the window class name.