It sets up an event handler for an automation object.
int SetEventHandlerForObject( Object * pObj, LPCSTR lpcszEventName, Function * pOCFunc )
0 if the event handler was set up successfully, 2 if an events COM interface cannot be retrieved from the object, 3 if the event name was wrong.
EX1
// This is the event handler which catches the event. The prototype must agree // with the event's declaration, which can be found out by inspecting // the object library for each particular object. void MyEventHandler() { printf("Event hanled\r\n"); } void SetEventHandlerForObject_ex1() { // Declare a function object (the function MyEventHandler must // have been defined before) Function fnEventHandler(MyEventHandler); Object obj = CreateObject("SomeObject.SomeObject"); int iRet; // This sets up the event handler. It tells the object obj: Call the function // MyEventHandler when event "SomeEvent" happens. iRet = SetEventHandlerForObject(&obj, "SomeEvent", &fnEventHandler); if (0 == iRet) out_str("Event handler set up successfully."); }
origin.h