You're talking about callback functions. Basically you give the object that's going to be using your code a pointer to the function you want it to use. Usually the pointer is passed in on the creation or initialisation of the object. Then, whenever the object wants to, it can call your function via the pointer you gave it.

There is a CALLBACK modifier to function declarations where that function will be called by a pointer to it, if I remember right the WindowProc function of a window is a callback so you should already know how that works. You may need to use that