user-0 提问: GetWindowLong与SetWindowLong 函数问题

回复:
user: user-1
content: 英语也是一门计算机语言的说。

user: user-0
content: 要是我英文好我早就去看MSDN了,关键是翻译软件翻译出来的也不好用~!

user: user-1
content: 1楼纯属胡扯！ SetWindowLong 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 );   Parameters hWnd  Handle to the window and, indirectly, the class to which the window belongs.  nIndex  Specifies the zero-based offset to the value to be set. Valid values are in the range zero through the number of bytes of extra window memory, minus 4; for example, if you specified 12 or more bytes of extra memory, a value of 8 would be an index to the third 32-bit integer. To set any other value, specify one of the following values: 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.     dwNewLong  Specifies the replacement value.  Return Values 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, callGetLastError.   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 callingSetLastError(0) before calling SetWindowLong. Then, function failure will be indicated by a return value of zero and a GetLastError result that is nonzero.  Remarks The SetWindowLong function fails if the window specified by the hWnd parameter does not belong to the same process as the calling thread.  Certain window data is cached, so changes you make using SetWindowLong will not take effect until you call the SetWindowPos function.  If you use SetWindowLong with 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.   If you use SetWindowLong with the DWL_MSGRESULT index to set the return value for a message processed by a dialog procedure, you should return TRUE directly afterwards. Otherwise, if you call any function that results in your dialog procedure receiving a window message, the nested window message could overwrite the return value you set using DWL_MSGRESULT.   Calling SetWindowLong with the GWL_WNDPROC index creates a subclass of the window class used to create the window. An application can subclass a system class, but should not subclass a window class created by another process. The SetWindowLong function creates the window subclass by changing the window procedure associated with a particular window class, causing the system 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 WNDCLASSEX structure used with the RegisterClassEx function.   You must not call SetWindowLong with the GWL_HWNDPARENT index to change the parent of a child window. Instead, use the SetParent function.   Windows CE: The nIndex parameter must be a multiple of 4 bytes.   Unaligned access is not supported.   The following nIndex parameter values are not supported:   GWL_HINSTANCE   GWL_HWNDPARENT   GWL_USERDATA   Windows CE versions 2.0 and later support the DWL_DLGPROC value in the nIndex parameter, but Windows CE 1.0 does not.  QuickInfo   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.  See Also Window Classes Overview, Window Class Functions, CallWindowProc, GetWindowLong, RegisterClassEx, SetParent, WindowProc, WNDCLASSEX     File: "C:\Program Files\Microsoft Visual Studio\VC98\Include\WINUSER.H"    7810: /*    7811:  * Get/SetWindowWord/Long offsets for use with WC_DIALOG windows    7812:  */    7813: #define DWL_MSGRESULT   0    7814: #define DWL_DLGPROC     4    7815: #define DWL_USER        8

user: user-1
content: ^异或 |或

user: user-2
content: SetWindowLong是一个Windows API函数。该函数用来改变指定窗口的属性．函数也将指定的一个32位值设置在窗口的额外存储空间的指定偏移位置。  SetWindowLong(hwnd, 0, 0);//这个函数的目的是什么？  这里就是将窗口的所有属性设置为0.  SetWindowLong(hwnd, 0, 1 ^ GetWindowLong(hwnd, 0));//还有这个函数我也不懂他的意思？  先获得窗口原来的属性，然后在这基础上做或运算，即加上一个1的属性，然后再将运算结果设置回原窗口。