DWORD SetClassLong(hwnd, nIndex, lNewVal) | |||||
HWND hwnd; | /* handle of window | */ | |||
int nIndex; | /* index of value to change | */ | |||
LONG lNewVal; | /* new value | */ |
This function replaces the long value specified by the nIndex parameter in the WNDCLASS structure of the window specified by the hwnd parameter.
hwnd
Identifies the window.
nIndex
Specifies the byte offset of the word to be changed. It can also be one of the following values:
Value | Meaning |
GCL_CBCLSEXTRA | ||
Sets how many bytes of additional class information you have. For information on how to access this memory, see the following “Comments” section. | ||
GCL_CBWNDEXTRA | ||
Sets how many bytes of additional window information you have. For information on how to access this memory, see the following “Comments” section. | ||
GCL_HBRBACKGROUND | ||
Sets a new handle to the background brush. | ||
GCL_HCURSOR | ||
Sets a new handle to the cursor. | ||
GCL_HICON | ||
Sets a handle to the icon. | ||
GCL_HMODULE | ||
Sets a handle to the module. | ||
GCL_MENUNAME | ||
Sets a pointer to the menu-name string. | ||
GCL_STYLE | ||
Sets the window-class style bits. | ||
GCL_WNDPROC | ||
Sets a pointer to the window function. |
lNewVal
Specifies the replacement value.
The return value specifies the previous value of the specified long integer.
If the SetClassLong function and GCL_WNDPROC index are used to set a window function, the given function must have the window-function form. See the RegisterClass function earlier in this chapter for details.
Calling SetClassLong with the GCL_WNDPROC index creates a subclass of the window class that affects all windows subsequently created with the class. See Chapter 1, Window Manager Interface Functions, for more information on window subclassing. An application should not subclass windows created by other processes, because it won't work.
To access any extra four-byte values allocated when the window-class structure was created, use a positive byte offset as the index specified by the nIndex parameter, starting at zero for the first four-byte value in the extra space, 4 for the next two-byte value and so on.
The SetClassLong function should be used with care. For example, it is possible to change the background color for a class by using SetClassLong, but this change does not cause all windows belonging to the class to be repainted immediately.
RegisterClass, GetClassLong, SetClassWord, GetClassWord