The event message routine has the following format.
It is a method of using the event message routine as a function of Visual C#.
When using WndProc, the event message routine is called whenever all events related to the application occur.
When using WndProc in C#, there is no automatic code generation function,
so please describe the part codes of the event message routine manually.
Create the function according to the following procedure.
1. Function declaration
Using the structure Message
in the class of System.Windows.Forms namespace, you can get the information
about messages sent from the system to applications and controls.
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand,
Name="FullTrust")]
protected override void WndProc (ref Message m)
2. Description of processing
Example : When output "Device Operation End Event has occurred"
if ( m.Msg == (short)CaioConst.AIOM_AIE_END ) {
label_Information.Text = "Device Operation End Event has occurred";
}
3. Base class WndProc processing
This processing should be performed after using the WndProc function.
base.WndProc(ref m);
4. Combining from 1 to 3, the event message routine has the following form.
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand,
ame="FullTrust")]
protected override void WndProc(ref Message m)
{
if ( m.Msg == (short)CaioConst.AIOM_AIE_END )
{
label_Information.Text = "Device Operation End Event has occurred";
}
base.WndProc(ref m);
}
To use event, it is necessary to set the window
handle of application to driver.
Use the following functions to set event.
Analog Input |
aio.SetAiEvent |
Analog Output |
aio.SetAoEvent |
Counter |
aio.SetCntEvent |
Timer |
aio.SetTmEvent |
Specify the window handle to parameter hWnd by these event setting functions.
In Visual C#, member variable Handle in .NET Framework class is the window handle, so please specify this member variable to the parameter.
Ret = aio.SetAiEvent ( Id , Handle , AiEvent ); |
Ret = aio.SetAoEvent ( Id , Handle , AoEvent ); |
Ret = aio.SetCntEvent ( Id , CntChannel , Handle , CntEvent ); |
Ret = aio.SetTmEvent ( Id , TimerId , Handle, TmEvent ); |