yup, You have to return the Value of the Procedure orelse it wont work.
This should work
GUICreate('Subclass Test - Phoenix XL', 450, 200)
GUICtrlCreateInput('Hello world!', 10, 45, 250, 20)
$TextBox = GUICtrlGetHandle(-1)
GUISetState()
$hHandle = DllCallbackGetPtr(DllCallbackRegister('MY_SUBCLASSPROC', 'LRESULT', 'HWND;UINT;WPARAM;LPARAM;UINT_PTR;DWORD_PTR'))
If ($hHandle == 0) Then
MsgBox(16, 'Subclass Test', 'Call to DllCallbackRegister failed.')
Exit
EndIf
SetWindowSubclass($TextBox, $hHandle, 0, 0)
If (@error) Then
MsgBox(16, 'Subclass Test', 'Call to SetWindowSubclass failed.')
Exit
EndIf
While (True)
Switch (GUIGetMsg())
Case -3 ;GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
RemoveWindowSubclass($TextBox, $hHandle, 0, 0)
Exit
Func MY_SUBCLASSPROC($hWnd, $uMsg, $wParam, $lParam, $uIdSubclass, $dwRefData)
ConsoleWrite($uMsg & @CRLF)
Return DefSubclassProc($hWnd, $uMsg, $wParam, $lParam)
EndFunc
Func SetWindowSubclass($hWnd, $pfnSubclass, $uIdSubclass, $dwRefData)
Local $bResult = DllCall('Comctl32.dll', 'BOOL', 'SetWindowSubclass', _
'HWND', $hWnd, _
'ptr', $pfnSubclass, _
'UINT_PTR', $uIdSubclass, _
'DWORD_PTR', $dwRefData)
If (@error) Or ($bResult[0] == 0) Then Return SetError(1, 0, 0)
Return SetError(0, 0, 1)
EndFunc
Func GetWindowSubclass($hWnd, $pfnSubclass, $uIdSubclass, ByRef $dwRefData)
Local $bResult = DllCall('Comctl32.dll', 'BOOL', 'GetWindowSubclass', _
'HWND', $hWnd, _
'ptr', $pfnSubclass, _
'UINT_PTR', $uIdSubclass, _
'DWORD_PTR*', 0)
If (@error) Or ($bResult[0] == 0) Then Return SetError(1, 0, 0)
$dwRefData = $bResult[4]
Return SetError(0, 0, 1)
EndFunc
Func RemoveWindowSubclass($hWnd, $pfnSubclass, $uIdSubclass, $dwRefData)
Local $bResult = DllCall('Comctl32.dll', 'BOOL', 'RemoveWindowSubclass', _
'HWND', $hWnd, _
'ptr', $pfnSubclass, _
'UINT_PTR', $uIdSubclass)
If (@error) Or ($bResult[0] == 0) Then Return SetError(1, 0, 0)
Return SetError(0, 0, 1)
EndFunc
Func DefSubclassProc($hWnd, $uMsg, $wParam, $lParam)
Local $aRet=DllCall('Comctl32.dll', 'LRESULT', 'DefSubclassProc', _
'HWND', $hWnd, _
'UINT', $uMsg, _
'WPARAM', $wParam, _
'LPARAM', $lParam)
Return $aRet[0]
EndFunc