Visual C++ (MFC)


It is a method of using the event message routine as a function of Visual C++.
When using DefWindowProc, the event message routine is called whenever all events related to the application are generated.

Creating event message routine

In Class View, right-click on the class to which you want to add the event message routine.
Then choose Add-Add Function. The Add Member Function Wizard dialog box is displayed.
Create the function according to the following procedure.

Return type

LRESULT

Function name

DefWindowProc

Parameter type

UINT

Parameter name

message

Add

Click the button

Parameter list

WPARAM

Parameter name

wParam

Add

Click the button

Parameter list

LPARAM

Parameter name

lParam

Add

Click the button

Access

protected

Virtual

Check the check box

Click the Finish button after confirming that Function signature is as follows.

virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);

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 :
Bank event. :
Extended events :

SmcWCountEvent
SmcWBankEvent
SmcWIrqEvent

Specify the window handle to the hWnd parameter in these event setting functions.
The m_hWnd member variable in MFC class contains the window handle In Visual C++ .NET. Please specify the member variable "as is".

Ret = SmcWStopEvent( Id , 1 , m_hWnd , 1 );
Ret = SmcWCountEvent( Id , 1 , m_hWnd, 1 , 0 , 500 )
Ret = SmcWBankEvent( Id , 1 , m_hWnd, 1, 3 )
Ret = SmcWCountEvent( Id , 1 , m_hWnd, 1 , 0 )