SetWindowLongW  (USER32.@)


 LONG SetWindowLongW
  HWND hwnd,
  INT  offset,
  LONG newval


hwnd [In] window to alter.
offset [In] offset,in bytes,of location to alter.
[In] new value of location.


SetWindowLongW (USER32.@) Set window attribute.

SetWindowLong alters one of a window's attributes or sets a 32-bit (long) value in a window's extra memory.

The _hwnd_ parameter specifies the handle to a window that has extra memory. The _newval_ parameter contains the new attribute or extra memory value. If positive, the _offset_ parameter is the byte-addressed location in the window's extra memory to set. If negative, _offset_ specifies the window attribute to set, and should be one of the following values:

GWL_EXSTYLE The window's extended window style.

GWL_STYLE The window's window style.

GWLP_WNDPROC Pointer to the window's window procedure.

GWLP_HINSTANCE The window's application instance handle.

GWLP_ID The window's identifier.

GWLP_USERDATA The window's user-specified data.

If the window is a dialog box, the _offset_ parameter can be one of the following values:

DWLP_DLGPROC The address of the window's dialog box procedure.

DWLP_MSGRESULT The return value of a message that the dialog box procedure processed.

DWLP_USER Application specific information.


If successful, returns the previous value located at _offset_. Otherwise, returns 0.


Extra memory for a window class is specified by a nonzero cbWndExtra parameter of the WNDCLASS structure passed to RegisterClass at the time of class creation.

Using GWL_WNDPROC to set a new window procedure effectively creates a window subclass. Use CallWindowProc in the new Windows® procedure to pass messages to the superclass's window procedure.

The user data is reserved for use by the application which created the window.

Do not use GWL_STYLE to change the window's WS_DISABLED style; instead, call the EnableWindow function to change the window's disabled state.

Do not use GWL_HWNDPARENT to reset the window's parent, use SetParent instead.

Win95: When offset is GWL_STYLE and the calling app's ver is 4.0, it sends WM_STYLECHANGING before changing the settings and WM_STYLECHANGED afterwards. App ver 4.0 can't use SetWindowLong to change WS_EX_TOPMOST.


Declared in "winuser.h".

Implemented in "dlls/user32/win.c".

Debug channel "win".

Copyright © 2022 The Wine Project. All trademarks are the property of their respective owners. Visit WineHQ for license details. Generated Sep 2022.