---
name: "SetWindowLongW"
section: "3w"
platform: "linux"
package: "libwine-dev"
version: "1.4.1-4"
release: "Debian 7 (Wheezy)"
platforms: ["linux"]
url: "https://new.carta.tech/SetWindowLongW"
---

# SetWindowLongW(3w)

## NAME

**SetWindowLongW** (USER32.@)

## SYNOPSIS

LONG SetWindowLongW\
  (\
   HWND *hwnd*,\
   INT  *offset*,\
   LONG *newval*\
  )

## PARAMS

*hwnd* **\[In\]**  window to alter.

*offset* **\[In\]**  *offset*,in bytes,of location to alter.

**\[In\]**  new value of location.

## DESCRIPTION

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 window. is 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 pplication 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.

## RETURNS

If successful, returns the previous value located at \_offset\_. Otherwise, returns **0.**

## NOTES

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

Using **GWL\_WNDPROC** to set a new window procedure effectively creates a window subclass. Use **CallWindowProc(3w)** in the new Windows(tm) 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(3w)](/EnableWindow/3w.md)** 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**.

## IMPLEMENTATION

Declared in **"winuser.h"**.

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

Debug channel **"win"**.
