Event message routine will be in the following format.
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
protected override void WndProc (ref Message m)
m.Msg
Message ID is passed.
m.WParam
ID is passed in lower 2 bytes. The channel number of counter in that the event occurred is passed in higher 2 bytes.
m.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 (The third argument "Window name" is optional).
switch( m.Msg ){
case AIOM_CNTE_DATA_NUM:
MessageBox.Show (this, "Comparison count match", "Window name");
break;
case AIOM_CNTE_ORERR:
MessageBox.Show (this, "Count overrun", "Window name");
break;
case AIOM_CNTE_ERR:
MessageBox.Show (this, "Count operation error", "Window name");
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) (The third argument "Window name" is optional).
if ( m.WParam = ID1 ){
switch( m.Msg ){
case AIOM_CNTE_DATA_NUM:
MessageBox.Show (this, "ID1: Comparison count match", "Window 1");
break;
case AIOM_CNTE_ORERR:
MessageBox.Show (this, "ID1: Count overrun", "Window 1");
break;
case AIOM_CNTE_ERR:
MessageBox.Show (this, "ID1: Count operation error", "Window 1");
break;
}
}
else{
switch( m.Msg ){
case AIOM_CNTE_DATA_NUM:
MessageBox.Show (this, "ID2: Comparison count match", "Window 2");
break;
case AIOM_CNTE_ORERR:
MessageBox.Show (this, "ID2: Count overrun", "Window 2");
break;
case AIOM_CNTE_ERR:
MessageBox.Show (this, "ID2: Count operation error", "Window 2");
break;
}
}