SetClassLong

2.x

  LONG SetClassLong(hwnd, nIndex, nVal)    
  HWND hwnd; /* handle of window, */  
  int nIndex; /* index of value to change */
  LONG nVal; /* new value */

The SetClassLong function sets a long value at the specified offset into the extra class memory for the window class to which the specified 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 long value to change. Valid values are in the range zero through the number of bytes of class memory, minus four. (For example, if 12 or more bytes of extra class memory were specified, a value of 8 would be an index to the third long integer.) This parameter can also be GCL_WNDPROC, which sets a new long pointer to the window procedure.

nVal

Specifies the replacement value.

Return Value

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

Comments

If the SetClassLong function and GCL_WNDPROC index are used to set a window procedure, the specified window procedure must have the window-procedure form and be exported in the module-definition file. For more information, see the description of the RegisterClass function.

Calling SetClassLong with the GCL_WNDPROC index creates a subclass of the window class that affects all windows subsequently created by using the class.

Applications should not call SetClassLong with the GCL_MENUNAME value.

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

See Also

GetClassLong, RegisterClass, SetClassWord