MSDN Documentation

WNDCLASSEX Structure

The WNDCLASSEX structure contains information about a window class. It is used with the RegisterClassEx function to register a window class for subsequent use in creating windows.

Definition
typedef struct _WNDCLASSEX {
    UINT      cbSize;
    UINT      style;
    WNDPROC   lpfnWndProc;
    int       cbClsExtra;
    int       cbWndExtra;
    HINSTANCE hInstance;
    HICON     hIcon;
    HCURSOR   hCursor;
    HBRUSH    hbrBackground;
    LPCSTR    lpszMenuName;
    LPCSTR    lpszClassName;
    HICON     hIconSm;
} WNDCLASSEX, *PWNDCLASSEX;

Members

MemberTypeDescription
cbSizeUINTSize of this structure, in bytes. Must be set to sizeof(WNDCLASSEX).
styleUINTClass style(s) (e.g., CS_VREDRAW, CS_HREDRAW).
lpfnWndProcWNDPROCPointer to the window procedure for this class.
cbClsExtraintNumber of extra bytes to allocate following the class structure.
cbWndExtraintNumber of extra bytes to allocate following the window instance.
hInstanceHINSTANCEHandle to the instance that contains the window procedure.
hIconHICONHandle to the class icon.
hCursorHCURSORHandle to the class cursor.
hbrBackgroundHBRUSHHandle to the class background brush.
lpszMenuNameLPCSTRResource name of the class menu, or NULL.
lpszClassNameLPCSTRString or atom that uniquely identifies the window class.
hIconSmHICONHandle to a small icon associated with the class.
C++ Example
#include <windows.h>

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
    switch (msg) {
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
        default:
            return DefWindowProc(hwnd, msg, wParam, lParam);
    }
}

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShowCmd) {
    WNDCLASSEX wc = {0};
    wc.cbSize        = sizeof(WNDCLASSEX);
    wc.style         = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc   = WndProc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = hInst;
    wc.hIcon         = LoadIcon(nullptr, IDI_APPLICATION);
    wc.hCursor       = LoadCursor(nullptr, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    wc.lpszMenuName  = nullptr;
    wc.lpszClassName = "MyWindowClass";
    wc.hIconSm       = LoadIcon(nullptr, IDI_APPLICATION);

    if (!RegisterClassEx(&wc)) {
        MessageBox(nullptr, "Window Registration Failed!", "Error", MB_ICONERROR);
        return 0;
    }

    HWND hwnd = CreateWindowEx(
        0,
        wc.lpszClassName,
        "Sample Window",
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT, 640, 480,
        nullptr, nullptr, hInst, nullptr);

    if (!hwnd) {
        MessageBox(nullptr, "Window Creation Failed!", "Error", MB_ICONERROR);
        return 0;
    }

    ShowWindow(hwnd, nShowCmd);
    UpdateWindow(hwnd);

    MSG msg;
    while (GetMessage(&msg, nullptr, 0, 0) > 0) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return (int)msg.wParam;
}

For more details, see the related pages: