The event message routine has the following format.
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
protected override void WndProc (ref Message m)
m.Msg
The message number is passed.
m.WParam
The ID is passed to the lower 2 bytes. The upper two bytes are not currently used.
m.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 (The third parameter "Window name" is optional).
switch( m.Msg ){
case AIOM_AOE_START :
MessageBox.Show (this, "Generating start", "Window name");
break;
case AIOM_AOE_RPTEND :
MessageBox.Show (this, "Repeat end", "Window name");
break;
case AIOM_AOE_END :
MessageBox.Show (this, "Generating end", "Window name");
break;
case AIOM_AOE_DATA_NUM :
MessageBox.Show (this, "Data stored", "Window name");
break;
case AIOM_AOE_SCERR :
MessageBox.Show (this, "Generating clock period error", "Window name");
break;
case AIOM_AOE_ADERR :
MessageBox.Show (this, "DA conversion error", "Window name");
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) (The third parameter "Window name" is optional).
if ( m.WParam = ID1 ){
switch( m.Msg ){
case AIOM_AOE_START :
MessageBox.Show (this, "ID1 : Generating start", "Window 1");
break;
case AIOM_AOE_RPTEND :
MessageBox.Show (this, "ID1 : Repeat end", "Window 1");
break;
case AIOM_AOE_END :
MessageBox.Show (this, "ID1 : Generating end", "Window 1");
break;
case AIOM_AOE_DATA_NUM :
MessageBox.Show (this, "ID1 : Data stored", "Window 1");
break;
case AIOM_AOE_SCERR :
MessageBox.Show (this, "ID1 : Generating clock period error", ”Window 1");
break;
case AIOM_AOE_ADERR :
MessageBox.Show (this, "ID1 : DA conversion error", "Window 1");
break;
}
}
else{
switch( m.Msg ){
case AIOM_AIE_START :
MessageBox.Show (this, "ID2 : Generating start", "Window 2");
break;
case AIOM_AIE_RPTEND :
MessageBox.Show (this, "ID2 : Repeat end", "Window 2");
break;
case AIOM_AIE_END :
MessageBox.Show (this, "ID2 : Generating end", "Window 2");
break;
case AIOM_AIE_DATA_NUM :
MessageBox.Show (this, "ID2 : Data stored", ”Window 2");
break;
case AIOM_AIE_SCERR :
MessageBox.Show (this, "ID2 : Generating clock period error", "Window 2");
break;
case AIOM_AIE_ADERR :
MessageBox.Show (this, "ID2 : DA conversion error", "Window 2");
break;
}
}