It is a method of using the event message routine as a function of Visual Basic .NET.(It is called VB .NET later)
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 VB .NET, 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.
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.
Protected Overrides Sub WndProc(ByRef
m As System.Windows.Forms.Message)
Handling
For example: When the stopped axis is outputted in a stop event
If m.Msg = CSMC_MESSAGE Then
szMsg = "AxisNo" + m.LParam.ToString
+ " was stop."
MessageBox.Show(szMsg, "Stop", MessageBoxButtons.OK)
End If
WndProc handling of the
base class
Perform the handling at the end of the WndProc function.
MyBase.WndProc(m)
Combining 1, 2 and 3, the event message routine is as follows.
Protected
Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Dim szMsg As String
Dim Title As String
If m.Msg = CSMC_MESSAGE Then
szMsg = "AxisNo"
+ m.LParam.ToString + " was stop."
MessageBox.Show(szMsg,
"Stop", MessageBoxButtons.OK)
End If
MyBase.WndProc(m)
End Sub
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 : |
SmcWStopEvent |
Count match event
: |
SmcWCountEvent |
Specify the window handle to the hWnd parameter in these event setting functions.
In Visual Basic .NET, the Handle member variable of the .NET Framework class owns the window handle. Please specify the member variable "as is".
Ret = SmcWStopEvent(
Id , 1 , Handle,
1 ) |