The GetWindowLong function retrieves information about the specified window. The function also retrieves the 32-bit (long) value at the specified offset into the extra window memory of a window.
LONG GetWindowLong(
HWND hWnd, // handle of window
int nIndex // offset of value to retrieve
);
Value | Action |
---|---|
GWL_EXSTYLE | Retrieves the extended window styles. |
GWL_STYLE | Retrieves the window styles. |
GWL_WNDPROC | Retrieves the address of the window procedure, or a handle representing the address of the window procedure. You must use the CallWindowProc function to call the window procedure. |
GWL_HINSTANCE | Retrieves the handle of the application instance. |
GWL_HWNDPARENT | Retrieves the handle of the parent window, if any. |
GWL_ID | Retrieves the identifier of the window. |
GWL_USERDATA | Retrieves the 32-bit value associated with the window. Each window has a corresponding 32-bit value intended for use by the application that created the window. |
The following values are also available when the hWnd parameter identifies a dialog box:
Value | Action |
---|---|
DWL_DLGPROC | Retrieves the address of the dialog box procedure, or a handle representing the address of the dialog box procedure. You must use the CallWindowProc function to call the dialog box procedure. |
DWL_MSGRESULT | Retrieves the return value of a message processed in the dialog box procedure. |
DWL_USER | Retrieves extra information private to the application, such as handles or pointers. |
If the function succeeds, the return value is the requested 32-bit value.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Reserve extra window memory by specifying a nonzero value in the cbWndExtra member of the WNDCLASSEX structure used with the RegisterClassEx function.
Windows CE: The nIndex parameter must be a multiple of 4 bytes. Unaligned access is not supported.
Windows CE does not support the GWL_HINSTANCE and GWL_HWNDPARENT values in the nIndex parameter.
Windows CE 1.0 also does not support the DWL_DLGPROC and GWL_USERDATA value in the nIndex parameter.
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
Import Library: Use user32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
Window Classes Overview, Window Class Functions, CallWindowProc, RegisterClassEx, SetParent, SetWindowLong, WNDCLASS