网站首页  词典首页

请输入您要查询的函数:

 

术语 setwindowlongptr
释义 SetWindowLongPtr
语法:
LONG_PTR SetWindowLongPtr( HWND hWnd,
int nIndex,
LONG_PTR dwNewLong
);
SetWindowLongPtr功能
该SetWindowLongPtr功能变化的一个指定的窗口属性。该函数还规定在指定的额外窗口内存偏移值。
这个函数取代SetWindowLong函数。要编写的代码是与32位和64位的Microsoft Windows,使用SetWindowLongPtr位版本的兼容。
参数
hWnd
[in]的窗口句柄,并间接地类所属的窗口。该SetWindowLongPtr函数失败如果该进程拥有hWnd参数所指定的窗口中,在用户界面特权隔离(UIPI)较高的程序特权比过程调用线程驻留英寸等级
微软Windows XP和更早的版本:在SetWindowLongPtr函数失败如果hWnd参数所指定的窗口不属于调用线程的相同的过程。
nIndex
[in]指定零的偏移值被设置。有效值范围在零通过额外的窗口内存的字节数,减去一个整数的大小。要设置任何其他值,指定下列值之一。
GWL_EXSTYLE
设置一个新的扩展窗口风格。有关更多信息,请参阅CreateWindowEx。
GWL_STYLE
设置一个新的窗口样式。
GWLP_WNDPROC
树立一个新的窗口过程的新地址。
GWLP_HINSTANCE
设置一个新的应用程序实例句柄。
GWLP_ID
设置一个新的窗口标识符。
GWLP_USERDATA
设置用户与窗口相关的数据。这些数据是为应用程序创建窗口的使用。最初它的价值为零。
下面的值也可当hWnd参数标识一个对话框。
DWLP_DLGPROC
设置新的指针指向对话框过程。
DWLP_MSGRESULT
设置在对话框过程处理消息的返回值。
DWLP_USER
设置新的额外的信息是私人的应用程序,如处理或指针。
dwNewLong
[in]指定替代的价值。
返回值
如果函数成功,返回值是指定的偏移以前的值。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
如果以前的值为零,函数成功,返回值是零,但功能不会清除最后一个错误的信息。要确定成败,清除通过调用SetLastError(0)最后一个错误信息,然后调用SetWindowLongPtr。功能衰竭时,也会出现零返回值和GetLastError函数的结果是非零。
备注
特定的窗口是缓存数据,所以改变您使用SetWindowLongPtr不会生效,直到您调用SetWindowPos函数。
如果您使用GWLP_WNDPROC指数SetWindowLongPtr取代窗口程序,窗口过程必须符合在的WindowProc回调函数的描述中指定的指导方针。
如果您使用DWLP_MSGRESULT指数SetWindowLongPtr设置一个对话框程序处理邮件中的返回值,对话框程序应直接返回TRUE之后。否则,如果调用任何函数在您的对话框过程的结果收到窗口消息,嵌套的窗口消息可能会覆盖的返回值通过使用DWLP_MSGRESULT集。
调用与GWLP_WNDPROC指数SetWindowLongPtr创建了一个用于创建窗口的窗口类的子类。应用程序可以子类系统类,但不应子窗口类由另一个进程创建的。该SetWindowLongPtr函数创建通过改变窗口过程与特定窗口类的子类相关的窗口,导致系统调用新的窗口过程而不是以前的1。应用程序必须通过没有新的窗口过程到以前的窗口过程处理,通过调用CallWindowProc任何消息。这允许应用程序创建一个窗口程序链。
通过指定储备在与RegisterClassEx函数所使用的WNDCLASSEX结构cbWndExtra成员非零值额外的窗口内存。
不要调用与GWLP_HWNDPARENT指数SetWindowLongPtr改变一个子窗口的父母。相反,使用SetParent函数。
如果窗口有CS_CLASSDC或CS_PARENTDC类的样式,不要设置扩展窗口样式WS_EX_COMPOSITED或WS_EX_LAYERED。
的Windows XP / Vista的:调用SetWindowLongPtr上设置一个ProgressBar的样式将重新定位。
功能信息
最低DLL版本 user32.dll
在Winuser.h中HeaderDeclared,头文件:winuser.h
import libraryUser32.lib
最低操作系统Windows 95,Windows NT 3.1
UnicodeImplemented为ANSI和Unicode版本。
参见
窗口类概述,CallWindowProc,GetWindowLongPtr,RegisterClassEx,SetParent,的WindowProc,窗口类
==英文原文==SetWindowLongPtr Function
The SetWindowLongPtr function changes an attribute of the specified window. The function also sets a value at the specified offset in the extra window memory.
This function supersedes the SetWindowLong function. To write code that is compatible with both 32-bit and 64-bit versions of Microsoft Windows, use SetWindowLongPtr.
Syntax
LONG_PTR SetWindowLongPtr( HWND hWnd,
int nIndex,
LONG_PTR dwNewLong
);
Parameters
hWnd
[in] Handle to the window and, indirectly, the class to which the window belongs. The SetWindowLongPtr function fails if the process that owns the window specified by the hWnd parameter is at a higher process privilege in the User Interface Privilege Isolation (UIPI) hierarchy than the process the calling thread resides in.
Microsoft Windows XP and earlier: The SetWindowLongPtr function fails 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 .
GWLP_WNDPROC
Sets a new address for the window procedure.
GWLP_HINSTANCE
Sets a new application instance handle.
GWLP_ID
Sets a new identifier of the window.
GWLP_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.
DWLP_DLGPROC
Sets the new pointer to the dialog box procedure.
DWLP_MSGRESULT
Sets the return value of a message processed in the dialog box procedure.
DWLP_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 offset.
If the function fails, the return value is zero. To get extended error information, call GetLastError .
If the previous value is zero and the function succeeds, the return value is zero, but the function does not clear the last error information. To determine success or failure, clear the last error information by calling SetLastError (0), then call SetWindowLongPtr. 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 SetWindowLongPtr will not take effect until you call the SetWindowPos function.
If you use SetWindowLongPtr with the GWLP_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 SetWindowLongPtr with the DWLP_MSGRESULT index to set the return value for a message processed by a dialog box procedure, the dialog box procedure should return TRUE directly afterward. Otherwise, if you call any function that results in your dialog box procedure receiving a window message, the nested window message could overwrite the return value you set by using DWLP_MSGRESULT.
Calling SetWindowLongPtr with the GWLP_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 SetWindowLongPtr 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.
Do not call SetWindowLongPtr with the GWLP_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_PARENTDC, do not set the extended window styles WS_EX_COMPOSITED or WS_EX_LAYERED.
Windows XP/Vista: Calling SetWindowLongPtr to set the style on a progressbar will reset its position.
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 Class Overview , CallWindowProc , GetWindowLongPtr , RegisterClassEx , SetParent , WindowProc , WNDCLASSEX
==原始网址==http://msdn.microsoft.com/en-us/library/ms644898(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 13:17:18