如果使用SetWindowLongPtr和GWLP_WNDPROC索引替换窗口过程,则窗口过程必须符合WindowProc回调函数的说明中指定的准则。 如果使用SetWindowLongPtr和DWLP_MSGRESULT索引来设置对话框过程处理的消息的返回值,则对话框过程应随后直接返回 true。 否则,如果调用任何导致对话框过程接收窗口消息的函数,则嵌套窗口消息可能会覆盖使用DWLP...
SetWindowLongPtr 是一个 Windows API 函数,用于设置窗口过程的地址。其函数原型如下: c LONG_PTR SetWindowLongPtr( HWND hWnd, int nIndex, LONG_PTR dwNewLong ); hWnd:指定要更改的窗口的句柄。 nIndex:要设置的值的索引。对于窗口过程,通常使用 GWLP_WNDPROC。 dwNewLong:新窗口过程的地址。 2. 编写一个...
使用GWLP_WNDPROC索引调用SetWindowLongPtr会创建用于创建窗口的窗口类的子类。 应用程序可以子类化系统类,但不应子类化由另一个进程创建的窗口类。SetWindowLongPtr函数通过更改与特定窗口类关联的窗口过程来创建窗口子类,导致系统调用新窗口过程而不是上一个窗口过程。 应用程序必须通过调用CallWindowProc将新窗口过程未处理的...
可以传入参数GWL_WNDPROC这一参数修改窗口的WndProc。但这里也明确提醒了我们,在开发同时兼容32位和64位程序时,微软建议我们使用SetWindowLongPtr这一函数,并传入GWLP_WNDPROC这一参数。原因在于:这里修改的WndProc实际上是修改函数指针,在64位系统下,指针已经从32位扩展到了64位,SetWindowLong的函数原型的第三个参数是3...
常用的属性索引包括GWLP_WNDPROC,用于更改窗口过程。 dwNewLong:新的窗口属性值。例如,当nIndex为GWLP_WNDPROC时,dwNewLong是新的窗口过程的指针。 用法示例: 以下代码示例展示了如何使用SetWindowLongPtr来更改一个窗口的窗口过程,从而实现自定义的消息处理。 c++ #include <windows.h> LRESULT CALLBACK WndProc(...
hwHilite = GetDlgItem(hwndDlg, IDC_HIGHLIGHT);SetWindowLongPtr( hwHilite, GWLP_WNDPROC, (LONG_PTR)Hilite2WndProc); slevSpin = SetupIntSpinner(hwndDlg, IDC_SLEV_SPIN, IDC_SLEV_EDIT,0,400,0); dlevSpin = SetupIntSpinner(hwndDlg, IDC_DLEV_SPIN, IDC_DLEV_EDIT,0,400,0); ...
#define SetWindowLongPtrW SetWindowLongW #ifdef UNICODE #define SetWindowLongPtr SetWindowLongPtrW #else #define SetWindowLongPtr SetWindowLongPtrA #endif // !UNICODE hWnd是窗口句柄。 nIndex是访问窗口对象数据的索引值。比如像GWLP_USERDATA、GWLP_WNDPROC。
CallingSetWindowLongPtrwith theGWLP_WNDPROCindex 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. TheSetWindowLongPtrfunction creates the window subclass by changing the windo...
#define SetWindowLongPtrW SetWindowLongW #ifdef UNICODE #define SetWindowLongPtrSetWindowLongPtrW #else #define SetWindowLongPtrSetWindowLongPtrA #endif // !UNICODE hWnd是窗口句柄。 nIndex是访问窗口对象数据的索引值。比如像GWLP_USERDATA、GWLP_WNDPROC。
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...