网站首页  词典首页

请输入您要查询的函数:

 

术语 setwindowlong
释义 SetWindowLong
语法:
LONG SetWindowLong( HWND hWnd,
int nIndex,
LONG dwNewLong
);
SetWindowLong函数
SetWindowLong函数变化的一个指定的窗口属性。该函数还规定在指定到额外的窗口内存偏移的32位(长)值。
注意:此功能已被取代的SetWindowLongPtr功能。写代码是与32位和64位版本的Microsoft Windows,使用SetWindowLongPtr功能兼容。
参数
hWnd
[in]
窗口句柄,并间接地类所属的窗口。
在Windows 95/98/Me:SetWindowLong函数可能会失败的hWnd参数指定的窗口不属于调用线程的相同的过程。
nIndex
[in]指定零的偏移值被设置。有效值范围在零通过额外的窗口内存的字节数,减去一个整数的大小。要设置任何其他值,指定下列值之一。
GWL_EXSTYLE
设置一个新的扩展窗口风格。有关更多信息,请参阅CreateWindowEx。
GWL_STYLE
设置一个新的窗口样式。
千万要小心
树立一个新的窗口过程的新地址。
Windows NT/2000/XP的:您不能更改此属性窗口,如果不属于作为调用线程相同的过程。
GWL_HINSTANCE
设置一个新的应用程序实例句柄。
GWL_ID
设置一个新的窗口标识符。
GWL_USERDATA
设置用户与窗口相关的数据。这些数据是为应用程序创建窗口的使用。最初它的价值为零。
下面的值也可当hWnd参数标识一个对话框。
DWL_DLGPROC
设置对话框的程序,新的地址。
DWL_MSGRESULT
设置在对话框过程处理消息的返回值。
DWL_USER
设置新的额外的信息是私人的应用程序,如处理或指针。
dwNewLong
[in]指定替代的价值。
返回值
如果函数成功,返回值是指定的32位整数以前的值。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
如果以前的值指定的32位整数是零,函数成功,返回值是零,但功能不会清除最后一个错误的信息。这使得很难确定成败。为了解决这个,您应该通过调用清除之前调用SetWindowLong函数SetLastError(0)最后一个错误的信息。然后,功能衰竭时,也会出现零返回值和GetLastError函数的结果是非零。
备注
特定的窗口是缓存数据,所以改变您使用SetWindowLong函数将不会生效,直到您调用SetWindowPos函数。特别是,如果您更改和风格的,您必须调用与缓存SWP_FRAMECHANGED标志SetWindowPos的更新正确。
如果您使用的千万要小心指数SetWindowLong函数替换窗口过程,窗口过程必须符合在的WindowProc回调函数的描述中指定的指导方针。
如果您使用DWL_MSGRESULT指数SetWindowLong函数设置一个对话框过程处理邮件中的返回值,您应该直接返回TRUE之后。否则,如果调用任何函数,在对话框的程序的结果收到窗口消息,嵌套的窗口消息可能会覆盖您的返回值设置使用DWL_MSGRESULT。
调用与千万要小心指数SetWindowLong函数创建了一个用于创建窗口的窗口类的子类。应用程序可以子类系统类,但不应子窗口类由另一个进程创建的。 SetWindowLong函数创建通过改变窗口过程与特定窗口类的子类相关的窗口,导致系统调用新的窗口过程而不是以前的1。应用程序必须通过没有新的窗口过程到以前的窗口过程处理,通过调用CallWindowProc任何消息。这允许应用程序创建一个窗口程序链。
通过指定储备在与RegisterClassEx函数所使用的WNDCLASSEX结构cbWndExtra成员非零值额外的窗口内存。
您不能调用与GWL_HWNDPARENT指数SetWindowLong函数改变一个子窗口的父母。相反,使用SetParent函数。
如果窗口有CS_CLASSDC或CS_OWNDC类的样式,不要设置扩展窗口样式WS_EX_COMPOSITED或WS_EX_LAYERED。
的Windows XP / Vista的:调用SetWindowLong函数上设置一个ProgressBar的样式将重新定位。
在Windows 95/98/Me:SetWindowLongW是支持的Unicode(MSLU)微软层。 SetWindowLongA也支持,提供更一致的行为,在所有的Windows操作系统。若要使用这些版本中,您必须添加一些文件到您的应用,概述了对Unicode的Microsoft层在Windows 95/98/Me系统。
例如
有关示例,请参见子类化一个窗口。
功能信息
最低DLL版本 user32.dll
在Winuser.h中HeaderDeclared,头文件:winuser.h
import libraryUser32.lib
最低操作系统Windows 95,Windows NT 3.1
UnicodeImplemented为ANSI和Unicode版本。
参见
窗口类的概述,CallWindowProc,GetWindowLong,RegisterClassEx,SetParent,SetWindowLongPtr,的WindowProc,窗口类
==英文原文==SetWindowLong Function
The SetWindowLong function changes an attribute of the specified window. The function also sets the 32-bit (long) value at the specified offset into the extra window memory.
Note This function has been superseded by the SetWindowLongPtr function. To write code that is compatible with both 32-bit and 64-bit versions of Microsoft Windows, use the SetWindowLongPtr function.
Syntax
LONG SetWindowLong( HWND hWnd,
int nIndex,
LONG dwNewLong
);
Parameters
hWnd
[in]
Handle to the window and, indirectly, the class to which the window belongs.
Windows 95/98/Me: The SetWindowLong function may fail if the window specified by the hWnd parameter does not belong to the same process as the calling thread.
nIndex
[in] 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 the size of an integer. To set any other value, specify one of the following values.
GWL_EXSTYLE
Sets a new extended window style. For more information, see CreateWindowEx .
GWL_STYLE
Sets a new window style .
GWL_WNDPROC
Sets a new address for the window procedure.
Windows NT/2000/XP: You cannot change this attribute if the window does not belong to the same process as the calling thread.
GWL_HINSTANCE
Sets a new application instance handle.
GWL_ID
Sets a new identifier of the window.
GWL_USERDATA
Sets the user data associated with the window. This data is intended for use by the application that created the window. Its value is initially zero.
The following values are also available when the hWnd parameter identifies a dialog box.
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
[in] Specifies the replacement value.
Return Value
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.
Remarks
Certain window data is cached, so changes you make using SetWindowLong will not take effect until you call the SetWindowPos function. Specifically, if you change any of the frame styles, you must call SetWindowPos with the SWP_FRAMECHANGED flag for the cache to be updated properly.
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 afterward. 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.
If the window has a class style of CS_CLASSDC or CS_OWNDC, do not set the extended window styles WS_EX_COMPOSITED or WS_EX_LAYERED.
Windows XP/Vista: Calling SetWindowLong to set the style on a progressbar will reset its position.
Windows 95/98/Me: SetWindowLongW is supported by the Microsoft Layer for Unicode (MSLU). SetWindowLongA is also supported to provide more consistent behavior across all Windows operating systems. To use these versions, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems .
Example
For an example, see Subclassing a Window .
Function Information
Minimum DLL Versionuser32.dll
HeaderDeclared in Winuser.h, include Windows.h
Import libraryUser32.lib
Minimum operating systemsWindows 95, Windows NT 3.1
UnicodeImplemented as ANSI and Unicode versions.
See Also
Window Classes Overview , CallWindowProc , GetWindowLong , RegisterClassEx , SetParent , SetWindowLongPtr , WindowProc , WNDCLASSEX
==原始网址==http://msdn.microsoft.com/en-us/library/ms633591(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:28:42