Visual C#


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 are generated.

Creating event message routine

When using WndProc in C#, the corresponding code cannot be generated automatically,
please add the source code related to the event message routine manually.

Create the function according to the following procedure.

  1. Declare the function
    By using the Message Structure in the Class of System.Windows.Forms namespace, it is possible to acquire the information related to messages being sent to the application and controls etc. from the system.

    [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
    protected override void WndProc (ref Message m)

  2. Handling
    For example: Output when "Detected out trigger state change"

    if ( m.Msg == (short)CSmcConst.CSMC_MESSAGE )
    {
        szText = string.Format("AxisNo {0:d} was stop.", m.LParam );
        MessageBox.Show(szText, "Stop Event", MessageBoxButtons.OK);
    }

  3. WndProc handling of the base class
    Perform the handling at the end of the WndProc function.

    base.WndProc(ref m);

  4. Combining 1, 2 and 3, the event message routine is as follows.

    [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, ame="FullTrust")]
    protected override void WndProc(ref Message m)
        if ( m.Msg == (short)CSmcConst.CSMC_MESSAGE )
        {
            szText = string.Format("AxisNo {0:d} was stop.", m.LParam );
            MessageBox.Show(szText, "Stop Event", MessageBoxButtons.OK);
        }
        base.WndProc(ref m);
    }

Specifying window handle

To use events, it is necessary to set the window handle of the application to the driver.
Use the following functions for event setting.

Motion stop event :

Smc.WStopEvent

Count match event :
Bank event :
Extended events :

Smc.WCountEvent
Smc.WBankEvent
Smc.WIrqEvent

Specify the window handle to the hWnd parameter in these event setting functions.

In Visual C#, the Handle member variable of the .NET Framework class owns the window handle. Please specify the member variable "as is".

Ret = Smc.WStopEvent( Id , 1 , Handle, 1 );

Ret = Smc.WCountEvent( Id , 1 , Handle, 1 , 0 , 500 );
Ret = Smc.WBankEvent( Id , 1 , Handle, 1, 3 )
Ret = Smc.WCountEvent( Id , 1 , Handle, 1 , 0 )