Visual C++ (MFC)

The event message routine has the following format.


Use DefWindowProc

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 occur.

Create Event Message Routine

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

[Return type]

LRESULT

[Function name]

DefWindowProc

[Parameter type]

UINT

[Parameter name]

message

[Add]

Click

[Parameter type]

WPARAM

[Parameter name]

wParam

[Add]

Click

[Parameter type]

LPARAM

[Parameter name]

lParam

[Add]

Click

[Access] 

protected

[Virtual]

Check the checkbox

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

virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
{
    Description of processing
}
return CDialog::DefWindowProc(message, wParam, lParam);

If there is no problem of the description, an event message routine has been created.

 

Specify Window Handle

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

Analog Input

AioSetAiEvent

Analog Output

AioSetAoEvent

Counter

AioSetCntEvent

Timer

AioSetTmEvent

Specify the window handle to parameter hWnd by these event setting functions.
In Visual C++ (MFC), member variable m_hWnd in MFC class is the window handle, so please specify this member variable to the parameter.

Ret = AioSetAiEvent ( Id , m_hWnd , AiEvent )
Ret = AioSetAoEvent ( Id , m_hWnd , AoEvent )
Ret = AioSetCntEvent ( Id , CntChannel , m_hWnd , CntEvent )
Ret = AioSetTmEvent ( Id , TimerId , m_hWnd , TmEvent )