Redirecting the WndProc is knows as subclassing this is kind of the default way the window message system works and if used right it poses no problems to existing callbacks, in fact you can stack these callbacks and call them in order if need be, you can intercept and redirect the callback of any window you can get the handle to
I don't have C++ code here this PB code should help explain the process,
Procedure agkWndProc(hwnd, uMsg, wParam, lParam)
; get the old proc
Define oldProc=GetProp_(hwnd, "oldProc")
Select uMsg
Case #WM_CLOSE
; remove the prop when the window closes
RemoveProp_(hwnd, "oldProc")
; your code here
EndSelect
; call the default proc
ProcedureReturn CallWindowProc_(oldProc, hwnd, uMsg, wParam, lParam)
EndProcedure
ProcedureCDLL Plugin_SetWindowTitle(name.s)
agkHWND = FindWindow_(#Null, S(name))
If IsWindow_(agkHWND)
; Get AGK window callback
*oldProc = GetWindowLongPtr_(agkHWND, #GWLP_WNDPROC)
; store the callback in a window prop
SetProp_(agkHWND, "oldProc", *oldProc)
; set our callback
SetWindowLongPtr_(agkHWND, #GWLP_WNDPROC, @agkWndProc())
Else
MessageRequester("CL", "Could not find window with name "+name)
EndIf
ProcedureReturn 0
EndProcedure
Plugin_SetWindowTitle is called from AppGameKit passing the title text, this gets a handle to the window and switches out the callback, in the custom callback we do what we need and call the default callback function, I use window props out of habit and convenience