I have an API (I have control over it) written in C that accepts a callback target. During execution, the API will call back presenting an event code and a void * for the event context. Its the basic WndProc model (where the LPARAM will be cast'ed to the appropriate struct pointer), where depending on the event the context is converted to a pointer to a structure specific to that event.
In C#, the callback works, thats simple. What doesnt work is my efforts to on event X, convert the void * context argument to a C# structure.
How do I get the generic void * argument converted to a C# struct of type X for an event type of X, and a type of Y for event type Y?
I can of course take the brute force method of setting multiple callback targets, one for each event type, where the callback context is a known structure type, but thats less than ideal. Then again, its a small set of events, so maybe ill go that way. Regardless, this is something id like to understand going forward.
Im hoping this is a function of the language (C#) that I do net understand fully, so ive listed this as 'easy'.