wcSetEventHandler( )

Syntax . . Returns . . Tips . . Program Example . . Related Topics . . A-Z Index . . Home

Specifies which function is called when a given event occurs.

Example

returnCode = wcSetEventHandler(cntrlHandle, "timeoutHandler", hndlTimeout);

Syntax

int wcSetEventHandler(void *controlHandle, 
                      char *handlerName, 
                      int (*function)() )
controlHandleThe handle to the control structure.
handlerNameThe name of the event handler.
functionA pointer to the function to be called to handle the event. Declare the function as follows:
int function(void *wcp)

Returns

0Success.
Error codeFailure or exception. For a list of possible error codes, see Error Messages.

Tips

Program Example

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<

Related Topics

wcCallEventHandler( )
<?MIEVENT> Tag


Top of Page . . Syntax . . Returns . . Tips . . Program Example . . A-Z Index . . Home