I'm faced with the daunting task of having to intercept and handle the WM_GETOBJECT
message whenever it is sent to any TWinControl
on a Form.
Obviously i'd prefer not to have to individually subclass every control:
Is there a way to be involved in the handling of every message sent directly to a child control using SendMessage
If you don't want to subclass each individual control (which is certainly an option, and one that can be simplified using interposer classes, for instance), then you can instead use a thread-specific WH_CALLWNDPROC
or WH_CALLWNDPROCRET
hook via the Win32 API SetWindowsHookEx()
function. The hooks will tell you which HWND
is receiving each message, and you don't need to implement the hooks in a DLL when hooking a thread in the same process as the hooker.
If you need the TWinControl*
pointer for a given HWND
, you can use the VCL's FindControl()
function in the Vcl.Controls
unit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With