The SetWindowLong function changes an attribute of the specified window. The function also sets a 32-bit (long) value at the specified offset into the extra window memory of a window.
LONG SetWindowLong(
HWND hWnd, |
// handle of window |
int nIndex, |
// offset of value to set |
LONG dwNewLong |
// new value |
); |
Value |
Action |
GWL_EXSTYLE |
Sets a new extended window style. |
GWL_STYLE |
Sets a new window style. |
GWL_WNDPROC |
Sets a new address for the window procedure. |
GWL_HINSTANCE |
Sets a new application instance handle. |
GWL_ID |
Sets a new identifier of the window. |
GWL_USERDATA |
Sets 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 |
Sets the new address of the dialog box procedure. |
DWL_MSGRESULT |
Sets the return value of a message processed in the dialog box procedure. |
DWL_USER |
Sets new extra information that is private to the application, such as handles or pointers. |
If the function succeeds, the return value is the previous value of the specified 32-bit integer.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
If the previous value of the specified 32-bit integer is zero, and the function succeeds, the return value is zero, but the function does not clear the last error information. This makes it difficult to determine success or failure. To deal with this, you should clear the last error information by calling SetLastError(0) before calling SetWindowLong. Then, function failure will be indicated by a return value of zero and a GetLastError result that is nonzero.
The SetWindowLong function fails if the window specified by the hWnd parameter does not belong to the same process as the calling thread.
If you use the SetWindowLong function and the GWL_WNDPROC index to replace the window procedure, the window procedure must conform to the guidelines specified in the description of the WindowProc callback function.
Calling SetWindowLong with the GWL_WNDPROC index creates a subclass of the window class used to create the window. An application should not subclass a window created by another process. The SetWindowLong function creates the window subclass by changing the window procedure associated with a particular window, causing Windows to call the new window procedure instead of the previous one. An application must pass any messages not processed by the new window procedure to the previous window procedure by calling CallWindowProc. This allows the application to create a chain of window procedures.
Reserve extra window memory by specifying a nonzero value in the cbWndExtra member of the WNDCLASS structure used with the RegisterClass function.
You must not call SetWindowLong with the GWL_HWNDPARENT index to change the parent of a child window. Instead, use the SetParent function.
CallWindowProc, GetWindowLong, GetWindowWord, RegisterClass, SetParent, SetWindowWord, WindowProc, WNDCLASS
file: /Techref/os/win/api/win32/func/src/f83_19.htm, 7KB, , updated: 2000/4/7 11:19, local time: 2024/11/23 11:48,
18.224.31.90:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://sxlist.com/techref/os/win/api/win32/func/src/f83_19.htm"> SetWindowLong</A> |
Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
Welcome to sxlist.com! |
.