Registering a Hook Function
Client applications receive WinEvents in a WinEventProc callback function. The actions performed by the callback function are defined by the application, but the syntax must be as specified in the prototype. Before it can receive events, the function must be registered by calling SetWinEventHook.
The parameters that the hook function receives tell the client about the window, object, and possible child element that generated the event. A client uses these parameters in an object retrieval call, such as AccessibleObjectFromEvent.
When registering the hook function, the client application specifies which events are to be handled by it. The client can call SetWinEventHook more than once to register different hook functions or to set additional events for a previously registered hook function is notified.
For example code, see SetWinEventHook.