Win32 API Reference

User Interface and Window Management

WindowClass Structure

The WNDCLASS structure contains information about a window class that is being registered by the RegisterClass function.

Structure Definition

typedef struct tagWNDCLASS {
    UINT      style;
    WNDPROC   lpfnWndProc;
    int       cbClsExtra;
    int       cbWndExtra;
    HINSTANCE hInstance;
    HICON     hIcon;
    HCURSOR   hCursor;
    HBRUSH    hbrBackground;
    LPCTSTR   lpszMenuName;
    LPCTSTR   lpszClassName;
} WNDCLASS, *PWNDCLASS, FAR* LPWNDCLASS;

Members

style

Specifies the window class style. This member can be any combination of the following values:

  • CS_BYTEALIGNCLIENT
  • CS_BYTEALIGNWINDOW
  • CS_CLASSDC
  • CS_DBLCLKS
  • CS_GLOBALCLASS
  • CS_HREDRAW
  • CS_PARENTDC
  • CS_SAVEBITS
  • CS_VREDRAW

Commonly used styles include CS_HREDRAW | CS_VREDRAW, which redraws the window whenever the window is moved or its size is changed.

lpfnWndProc

A pointer to the window procedure, a callback function that processes messages sent to this window.

WNDPROC is a pointer to a window procedure, defined as:

LRESULT CALLBACK WindowProc(
      HWND hwnd,
      UINT uMsg,
      WPARAM wParam,
      LPARAM lParam
    );

cbClsExtra

The number of extra bytes requested per class, in bytes. The application must allow enough space in the extra class memory to store data needed by the driver.

cbWndExtra

The number of extra bytes requested per window, in bytes. The application must allow enough space in the extra window memory to store data needed by the application.

hInstance

A handle to the instance of the module that creates the window. This is typically obtained by calling the GetModuleHandle function with NULL.

hIcon

A handle to the class icon. This member must be a handle to the icon resource. If this member is NULL, an application-defined default icon is used.

hCursor

A handle to the class cursor. If this member is NULL, the system will attempt to retrieve the default cursor associated with the class.

hbrBackground

A handle to the class background brush. This handle must be a handle to a bitmap, a color value, or a user-defined pattern. If this member is NULL, an application must paint its own background.

lpszMenuName

A pointer to a null-terminated string that specifies the resource name of the class menu, as the name appears in the resource file. If this member is NULL, windows in this class have no menu.

lpszClassName

A pointer to a null-terminated string that specifies the window class name. This name must be unique among all the registered classes for the current process.

This name can be an arbitrary string, or it can be one of the system-defined atom names.

Related Functions

See Also

Window Creation, Window Procedures