User`s manual

Table Of Contents
UC-7400-CE User’s Manual Programming Examples
5-10
All you need to do is register your callback function to an associated keypad with the function in
the format (unsigned int key, void* param). The argument param is used to transfer your private
data to the callback function.
#include <windows.h>
#include <moxa/devices.h>
FKEYHNDL(keyF2)
{
printf("keyF2 is pressed\n");
return 0;
}
FKEYHNDL(keyF3)
{
printf("keyF3 is pressed\n");
return 0;
}
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
HANDLE hEvent;
DWORD rtn;
if (mxfkey_init())
return 1;
rtn = mxfkey_register("F2", keyF2, 0);
if (rtn)
return 1;
rtn = mxfkey_register("F3", keyF3, 0);
if (rtn)
{
mxfkey_stop();
return 1;
}
hEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
WaitForSingleObject( hEvent,20000 );
mxfkey_stop();
return 0;