In VC, the event message routine has the following format.
LRESULT CAioDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
message
The message number is passed.
wParam
The ID is passed to the lower
2 bytes. The upper two bytes are not currently used.
lParam
Parameters specific to each event are passed.
Message Processing Example 1
If there is only one device that uses the event, the device's decision
by ID is not particularly necessary. The following code shows an example
of displaying a message box when an event occurs.
switch( message ){
case AIOM_AOE_START :
AfxMessageBox("Generating start", MB_OK,
0);
break;
case AIOM_AOE_RPTEND :
AfxMessageBox("Repeat end", MB_OK, 0);
break;
case AIOM_AOE_END :
AfxMessageBox("Generating end", MB_OK,
0);
break;
case AIOM_AOE_DATA_NUM :
AfxMessageBox("Data stored", MB_OK, 0);
break;
case AIOM_AOE_SCERR :
AfxMessageBox("Generating clock period error",
MB_OK, 0);
break;
case AIOM_AOE_ADERR :
AfxMessageBox("DA conversion error",
MB_OK, 0);
break;
}
Message Processing Example 2
When using events on multiple devices, you need to decide which device
generated event. The following code is an example of using events on two
devices (ID1 and ID2).
if ( wParam = ID1 ){
switch( message ){
case AIOM_AOE_START :
AfxMessageBox("ID1
: Generating start", MB_OK, 0);
break;
case AIOM_AOE_RPTEND :
AfxMessageBox("ID1
: Repeat end", MB_OK, 0);
break;
case AIOM_AOE_END :
AfxMessageBox("ID1
: Generating end", MB_OK, 0);
break;
case AIOM_AOE_DATA_NUM :
AfxMessageBox("ID1
: Data stored", MB_OK, 0);
break;
case AIOM_AOE_SCERR :
AfxMessageBox("ID1
: Generating clock period error", MB_OK, 0);
break;
case AIOM_AOE_ADERR :
AfxMessageBox("ID1
: DA conversion error", MB_OK, 0);
break;
}
}
else{
switch( message ){
case AIOM_AOE_START :
AfxMessageBox("ID2
:Generating start", MB_OK, 0);
break;
case AIOM_AOE_RPTEND :
AfxMessageBox("ID2
:Repeat end", MB_OK, 0);
break;
case AIOM_AOE_END :
AfxMessageBox("ID2
:Generating end", MB_OK, 0);
break;
case AIOM_AOE_DATA_NUM :
AfxMessageBox("ID2
:Data stored", MB_OK, 0);
break;
case AIOM_AOE_SCERR :
AfxMessageBox("ID2
:Generating clock period error", MB_OK, 0);
break;
case AIOM_AOE_ADERR :
AfxMessageBox("ID2
:DA conversion error", MB_OK, 0);
break;
}
}