Remix.run Logo
CodesInChaos 16 hours ago

Well designed C APIs have a context/userdata parameter on their callbacks, which is registered and stored alongside the function pointer. Unfortunately WNDPROC lacks this parameter.

GWLP_USERDATA should be the best option, though the API for setting it and setting the WNDPROC being separate looks error prone.

publicdebates 15 hours ago | parent [-]

The bigger problem is that I would have to automate this for every callback type in the Windows API, and there's no guarantee that all of them follow the same 2 or 3 patterns for passing the context pointer into the callback. This solution works great, even if it is a bit wasteful of the ctx ptr.