SetClassWord

2.x

  WORD SetClassWord(hwnd, nIndex, wNewWord)    
  HWND hwnd; /* handle of window, */  
  int nIndex; /* index of value to change */
  WORD wNewWord; /* new value, */  

The SetClassWord function sets a word value at the specified offset into the extra class memory for the window class to which the given window belongs. Extra class memory is reserved by specifying a nonzero value in the cbClsExtra member of the WNDCLASS structure used with the RegisterClass function.

Parameters

hwnd

Identifies the window.

nIndex

Specifies the zero-based byte offset of the word value to change. Valid values are in the range zero through the number of bytes of class memory, minus two (for example, if 10 or more bytes of extra class memory were specified, a value of 8 would be an index to the fifth integer), or one of the following values:

Value Meaning

GCW_HBRBACKGROUND Sets a new handle of a background brush.
GCW_HCURSOR Sets a new handle of a cursor.
GCW_HICON Sets a new handle of an icon.
GCW_STYLE Sets a new style bit for the window class.

wNewWord

Specifies the replacement value.

Return Value

The return value is the previous value of the specified word, if the function is successful. Otherwise, it is zero.

Comments

The SetClassWord function should be used with care. For example, it is possible to change the background color for a class by using SetClassWord, but this change does not cause all windows belonging to the class to be repainted immediately. Applications should not attempt to set the class word values of any class attribute except those listed for the nIndex parameter.

To access any extra 2-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 0 for the first 2-byte value in the extra space, 2 for the next 2-byte value, and so on.

See Also

GetClassWord, RegisterClass, SetClassLong