Function Reference


_WinAPI_SetWindowSubclass

Installs or updates a window subclass callback

#include <WinAPIShellEx.au3>
_WinAPI_SetWindowSubclass ( $hWnd, $pSubclassProc, $idSubClass [, $pData = 0] )

Parameters

$hWnd Handle of the window being subclassed.
$pSubclassProc A pointer to a window procedure. This pointer and the subclass ID uniquely identify this subclass callback.
(See MSDN for more information)
$idSubClass The subclass ID.
$pData [optional] The reference data. This value is passed to the subclass procedure. The meaning of this value is determined by the calling application.

Return Value

Success: True.
Failure: False.

Remarks

Subclass callbacks are identified by the combination of the callback address and the caller-defined subclass ID.
If the callback address and ID pair have not yet been installed, then this function installs the subclass,
otherwise, this function just updates the reference data.

See Also

Search SetWindowSubclass in MSDN Library.

Example

#include <Extras\WMDebug.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIShellEx.au3>

OnAutoItExitRegister('OnAutoItExit')

; Create GUI
Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'))

; Register DLL callback that will be used as window subclass procedure
Global $g_hDll = DllCallbackRegister('_SubclassProc', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr')
Global $g_pDll = DllCallbackGetPtr($g_hDll)

; Install window subclass callback
_WinAPI_SetWindowSubclass($g_hForm, $g_pDll, 1000, 0)

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _SubclassProc($hWnd, $iMsg, $wParam, $lParam, $iID, $pData)
    #forceref $iID, $pData
    ; Declared in WMDebug.au3
    _WM_Debug($hWnd, $iMsg, $wParam, $lParam)
    Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_SubclassProc

Func OnAutoItExit()
    _WinAPI_RemoveWindowSubclass($g_hForm, $g_pDll, 1000)
    DllCallbackFree($g_hDll)
EndFunc   ;==>OnAutoItExit