Generally, whenever we want to wrap a Window/Thread in a C++ object, we do so by passing the this
pointer via SetWindowLong/GetWindowLong
or SetProp/GetProp
for a Window, and as lpParameter
for CreateThread
/etc.
My question is specific to Hooks. What is the elegant approach to pass the 'this' pointer to SetWindowsHookEx's callback procedures, or in other words How to wrap a hook's callback procedure ?
Since SetWindowsHookEx
does not accept any UserData argument, I don't see much options apart from using un-encapsulated i.e. global/static/TLS data.