The event message routine has the following format.
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
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.
Select Case Message
Case AIOM_AOE_START
MsgBox "Device ID: " & m.WParam & Chr$(13), , "Generating start"
Case AIOM_AOE_RPTEND
MsgBox "Device ID: " & m.WParam & Chr$(13) & "Repeat Times : " & m.LParam, , "Repeat end"
Case AIOM_AOE_END
MsgBox "Device ID: " & m.WParam & Chr$(13) & "Generating Times : " & m.LParam, , "Generating end"
Case AIOM_AOE_DATA_NUM
MsgBox "Device ID: " & m.WParam & Chr$(13) & "Generating Times : " & m.LParam, , "Data stored"
Case AIOM_AOE_SCERR
MsgBox "Device ID: " & m.WParam & Chr$(13) & "Generating Times : " & m.LParam, , "Generating clock period error"
Case AIOM_AOE_ADERR
MsgBox "Device ID: " & m.WParam & Chr$(13) & "Generating Times : " & m.LParam, , "DA conversion error"
End Select
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 m.WParam = ID1 Then
Select Case Message
Case AIOM_AOE_START
MsgBox "Device 1" & Chr$(13), , "Generating start"
Case AIOM_AOE_RPTEND
MsgBox "Device 1" & Chr$(13) & "Repeat Times : " & m.LParam, , "Repeat end"
Case AIOM_AOE_END
MsgBox "Device 1" & Chr$(13) & "Generating Times : " & m.LParam, , "Generating end"
Case AIOM_AOE_DATA_NUM
MsgBox "Device 1" & Chr$(13) & "Generating Times : " & m.LParam, , "Data stored"
Case AIOM_AOE_SCERR
MsgBox "Device 1" & Chr$(13) & "Generating Times : " & m.LParam, , "Generating clock period error"
Case AIOM_AOE_ADERR
MsgBox "Device 1" & Chr$(13) & "Generating Times : " & m.LParam, , "DA conversion error"
End Select
Else
Select Case Message
Case AIOM_AOE_START
MsgBox "Device 2" & Chr$(13), , "Generating start"
Case AIOM_AOE_RPTEND
MsgBox "Device 2" & Chr$(13) & "Repeat Times : " & m.LParam, , "Repeat end"
Case AIOM_AOE_END
MsgBox "Device 2" & Chr$(13) & "Generating Times : " & m.LParam, , "Generating end"
Case AIOM_AOE_DATA_NUM
MsgBox "Device 2" & Chr$(13) & "Generating Times : " & m.LParam, , "Data stored"
Case AIOM_AOE_SCERR
MsgBox "Device 2" & Chr$(13) & "Generating Times : " & m.LParam, , "Generating clock period error"
Case AIOM_AOE_ADERR
MsgBox "Device 2" & Chr$(13) & "Generating Times : " & m.LParam, , "DA conversion error"
End Select
EndIf