The new event handler must pass unhandled events to the previous event handler by calling the previous event handler stored in the handler descriptor using the macro HANDLERDESC_Call().
Applications can 'chain' multiple event handlers on an object by calling IHandler_SetHandler() multiple times with different HandlerDesc data structures.
To uninstall a handler from the chain, call IHandler_SetHandler() a second time with the same HandlerDesc data structure. This will swap the new and previous event handlers back to the state they were before the handler was installed. If multiple handlers are installed, they must be uninstalled in the reverse order from which they were installed. The following example may help to illustrate. (Note that chaining multiple handlers in this way is not likely to be useful, it is only shown here to demonstrate the mechanics of multiple handlers.)
HandlerDesc hdNew1, hdNew2, hdNew3; // install 3 handlers IForm_SetHandler(po, &hdNew1); IForm_SetHandler(po, &hdNew2); IForm_SetHandler(po, &hdNew3); // later, undo the above handler chaining IForm_SetHandler(po, &hdNew3); IForm_SetHandler(po, &hdNew2); IForm_SetHandler(po, &hdNew1);
void IHandler_SetHandler(IHandler *pif, HandlerDesc *pd);
- IHandler_SetHandler() fills the HandlerDesc data structure pointed to by 'pd' with the previous event handler, context pointer and free callback. The application should save the contents of the HandlerDesc data structure and pass unhandled events to the previous event handler and context pointer. The macro HANDLERDESC_Call() may be used as a convenience for this call.