The event handler is stored in a HandlerDesc data structure as a PFNHANDLER, along with a pointer to a block of memory allocate and owned by the decorator implementation. This pointer will be passed into the decorator's event handler with each event to be processed. The HandlerDesc data structure also contains a PFNFREEHANDLER that will be called when the decorator is released so that the decorator may free the private memory allocated and passed to the event handler.
IDecorator_SetHandler() associates a given HandlerDesc data structure with a particular decorator.
- p:[in] A pointer to an IDecorator object.
- pd:[in] Pointer to the data structure that contains the event handler, private memory pointer, and the callback used to free the private memory.
void IDecorator_SetHandler(IDecorator *p, HandlerDesc *pd);
The handler installed by a decorator to process events should itself remember to call HANDLERDESC_Call() so that the implementations that themselves derive from this decorator may also to hook into the decorator's event handler.