Jump to content

Window class

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Jamesday (talk | contribs) at 15:04, 27 October 2003 (Expanded the description, with minimum supporting Windows versions.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

This page has been listed on Wikipedia:Votes for deletion. Please see that page for justifications and discussion.

In Microsoft Windows programming a window class is a structure declared using C programming language's struct as WNDCLASS or WNDCLASSEX and holds a set of attributes which the system uses to create a process-specific process-specific window class[1][2]:

typedef struct {
    UINT style;              // Type of window- button, combo box etc.
    WNDPROC lpfnWndProc;     // a function Windows calls back to handle messages to the window
    int cbClsExtra;          // any extra bytes wanted after the structure
    int cbWndExtra;          // DLGWINDOWEXTRA if a dialog box will be used
    HINSTANCE hInstance;     // handle to the instance containing the window procedure for the class
    HICON hIcon;             // handle to the class icon
    HCURSOR hCursor;         // handle to the class cursor
    HBRUSH hbrBackground;    // handle to class background brush
    LPCTSTR lpszMenuName;    // pointer to resource name of the class menu
    LPCTSTR lpszClassName;   // pointer to null-terminated string or an atom
} WNDCLASS, *PWNDCLASS;

or

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

The program creating the new window class sets the values in the structure and then passes a pointer to it to the operating system via a call to the RegisterClass or RegisterClassX function.

The minimum operating system versions for this feature are Windows 95 or Windows NT 3.1. These window classes were not present in Windows versions 1.0 through 3.11 (Windows for Workgroups)[3].

Dispute

The window class has been disputed if it is a class in the sense of OOP or not. See dispute over the definition of object-oriented programming for the details.