Event message routine of the VC will be in the following format.
LRESULT CAioDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
message
Message ID is passed.
wParam
ID is passed in lower 2 bytes. The channel number of counter in that the event occurred is passed in higher 2 bytes.
lParam
The parameter peculiar to event is passed.
Example 1 for processing message
If there is only 1 device that uses the event, the determination of device by ID is not particularly necessary. The following code shows an example for displaying a message box when an event occurs.
switch( message ){
case AIOM_CNTE_DATA_NUM:
AfxMessageBox("Comparison count match", MB_OK, 0);
break;
case AIOM_CNTE_ORERR:
AfxMessageBox("Count overrun", MB_OK, 0);
break;
case AIOM_CNTE_ERR:
AfxMessageBox("Count operation error", MB_OK, 0);
break;
}
Example 2 for processing message
If there are multiple devices that use the event, you need to determine which device generated event. The following code is an example for using an event on 2 devices (ID1 and ID2).
if ( wParam = ID1 ){
switch( message ){
case AIOM_CNTE_DATA_NUM:
AfxMessageBox("ID1: Comparison count match", MB_OK, 0);
break;
case AIOM_CNTE_ORERR:
AfxMessageBox("ID1: Count overrun", MB_OK, 0);
break;
case AIOM_CNTE_ERR:
AfxMessageBox("ID1: Count operation error", MB_OK, 0);
break;
}
}
else{
switch( message ){
case AIOM_CNTE_DATA_NUM:
AfxMessageBox("ID2: Comparison count match", MB_OK, 0);
break;
case AIOM_CNTE_ORERR:
AfxMessageBox("ID2: Count overrun", MB_OK, 0);
break;
case AIOM_CNTE_ERR:
AfxMessageBox("ID2: Count operation error", MB_OK, 0);
break;
}
}