Specifies which function is called when a given event occurs.
returnCode = wcSetEventHandler(cntrlHandle, "timeoutHandler", hndlTimeout);
int wcSetEventHandler(void *controlHandle, char *handlerName, int (*function)() )
controlHandle | The handle to the control structure. |
handlerName | The name of the event handler. |
function | A pointer to the function to be called to handle the event. Declare the function as follows:
int function(void *wcp) |
0 | Success. |
Error code | Failure or exception. For a list of possible error codes, see Error Messages. |
In the following example, an event handler function runs a query to populate a list box in the HTML page.
/* Declare the event handling function */ int nameList(controlHandle) void *controlHandle; { WebSelectList(cntrlHandle, "select last_name from customers", "NAME=last&VALUE=selectList1", NULL); } int requestLoop(controlHandle) void *controlHandle; { char *pageText; wcConOpen(controlHandle, 0); /* Associate nameList( ) with the "List" event */ wcSetEventHandler(controlHandle, "List", nameList); /* Load and explode the AppPage */ wcLoad(controlHandle, "page", &pageText); WebExplode(controlHandle, pageText, NULL); wcConClose(controlHandle); }
The nameList( ) function is called when WebExplode( ) encounters the following tag in the AppPage:
<HTML> <BODY< ... <?MIEVENT NAME="List"> ... </HTML> </BODY<
wcCallEventHandler( )
<?MIEVENT> Tag