/*
	'C' EXAMPLE FOR USING DEFERRED EVENTS

The following is an example of how to use deferred events within 'C'. An electronic 
copy of this example is also available from VideoLogic Regional Support Groups and 
from the VideoLogic section of the CompuServe MULTIVEN forum (GO VIDEOLOGIC).

This example is a skeleton which needs to be filled out to complete the required 
application, but it does demonstrate the required Windows communication and message 
passing process.

*/

#define WM_MIC_NOTIFY   (WM_USER + 1)

char    szResponse[256];
DWORD   dwMICId;

LONG FAR PASCAL MainWndProc(HWND hWnd, UINT message,            
				WPARAM wParam, LPARAM lParam)
{
	LONG            lRet;
	WORD            wRet;

	lRet = 0L;
	switch (message)
	{
		case WM_CREATE:
			wRet = MICOpen(&dwMICId);
			if (wRet == MIC2_OK)
			{
				/* MIC has been opened OK */

				/* register this window for MIC notify          
						messages */
				MICNotify(dwMICId, (DWORD) hWnd,                
					(DWORD) WM_MIC_NOTIFY);
			}
 
			...

			lRet = 1L;
			break;


		case WM_MIC_NOTIFY:             /* message: from MIC */
			wRet = MICReadDef(dwMICId, szResponse,          
						sizeof(szResponse));
			if (wRet == MIC2_OK)
			{
				/* Deferered response read OK */

				/* process deferred response here */
			}
			lRet = 1L;
			break;

		case WM_DESTROY:                /* message: window being        
						destroyed */
			/* unregister this window for MIC notify messages */
			MICNotify(dwMICId, (DWORD) 0, (DWORD) 0);
			/* close MIC */
			MICClose(&dwMICId);

			...

			lRet = 1L;
			break;

		...

		default:                        /* Passes it on if                      
						unproccessed    */
			lRet = DefWindowProc(hWnd, message, wParam,             
						lParam);
			break;
	}
	return (lRet);
}
