安装或更新窗口子类回调
#Include <WinAPIEx.au3>
_WinAPI_SetWindowSubclass ( $hWnd, $pSubclassProc, $ID [, $pData] )
$hWnd | 拥有子类的窗口的句柄 |
$pSubclassProc | 窗口进程的指针. 该指针及子类的唯一ID标识该子类的回调. (更多信息参考MSDN) |
$ID | 子类ID |
$pData | [可选参数] 引用数据. 该值传递到子类进程. 该值的意思由调用的应用程序决定. |
成功: | 返回 1. |
失败: | 返回 0并设置@error非0. |
在MSDN中搜索
#Include <WinAPIEx.au3>
#Include <Extras\WMDebug.au3>
Opt('MustDeclareVars', 1)
Global $hForm, $hDll, $pDll
OnAutoItExitRegister('OnAutoItExit')
; 创建 GUI
$hForm = GUICreate('MyGUI')
; Register DLL callback that will be used as window subclass procedure
$hDll = DllCallbackRegister('_SubclassProc', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr')
$pDll = DllCallbackGetPtr($hDll)
; Install window subclass callback
_WinAPI_SetWindowSubclass($hForm, $pDll, 1000, 0)
GUISetState()
Do
Until GUIGetMsg() = -3
Func _SubclassProc($hWnd, $iMsg, $wParam, $lParam, $ID, $pData)
; Declared in WMDebug.au3
_WM_Debug($hWnd, $iMsg, $wParam, $lParam)
Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
EndFunc ;==>_SubclassProc
Func OnAutoItExit()
_WinAPI_RemoveWindowSubclass($hForm, $pDll, 1000)
DllCallbackFree($hDll)
EndFunc ;==>OnAutoItExit