GetWindowLong

2.x

  LONG GetWindowLong(hwnd, nOffset)    
  HWND hwnd; /* handle of window, */  
  int nOffset; /* offset of value to retrieve */

The GetWindowLong function retrieves a long value at the specified offset into the extra window memory of the given window. Extra window memory is reserved by specifying a nonzero value in the cbWndExtra member of the WNDCLASS structure used with the RegisterClass function.

Parameters

hwnd

Identifies the window.

nOffset

Specifies the zero-based byte offset of the value to be retrieved. Valid values are in the range zero through the number of bytes of extra window memory, minus four (for example, if 12 or more bytes of extra memory was specified, a value of 8 would be an index to the third long integer), or one of the following values:

Value Meaning

GWL_EXSTYLE Extended window style
GWL_STYLE Window style
GWL_WNDPROC Long pointer to the window procedure

The following values are also available when the hwnd parameter identifies a dialog box:

Value Meaning

DWL_DLGPROC Specifies the address of the dialog box procedure.
DWL_MSGRESULT Specifies the return value of a message processed in the dialog box procedure.
DWL_USER Specifies extra information that is private to the application, such as handles or pointers.

Return Value

The return value specifies information about the given window if the function is successful.

Comments

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 nOffset 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

GetWindowWord, SetWindowLong, SetWindowWord