WinCEGeräteSE_Handbuch_Programmierung_v3.00_EN
31 / 65
5.7.2.2 Triggering a scan from the application
The ScanDrv scanner driver is responsible for comfortably rendering the scanner keys.
The developer can also render the scanner keys:
A Windows system message sends the command to the application to press/release the scanner keys. The
name of the Windows message is defined in the intscanner.h header file of acddev.dll. This can be found in
a device-specific subfolder of \Dev_ACDDev.dll on the developer CD.
The wParam of the event routine sends the new status of the scanner keys (SC_MAKE, SC_BREAK).
A segment of a code as an example:
// Get ID for scanner message
UINT
uScannerMsg = RegisterWindowMessage(MESSAGETXT_SCANNER);
// Assign message to a function
BEGIN_MESSAGE_MAP(CM200CtlDlg, CDialog)
//{{AFX_MSG_MAP(CM200CtlDlg)
...
//}}AFX_MSG_MAP
ON_REGISTERED_MESSAGE (uScannerMsg, OnScannerMsg)
END_MESSAGE_MAP()
// Process scanner message
afx_msg LRESULT CMyAppDlg::OnScannerMsg(WPARAM wParam, LPARAM lParam)
{
switch (wParam)
{
case SC_MAKE:
// Code scanner key pressed
break;
case SC_BREAK:
// Code scanner key released
break;
}
return FALSE;
}
The ACD DeveloperPack offers among other features useful functions for the scanner module installed in
ACD devices.
5.7.2.3 The callback function
In the application, a callback function is defined whose address is sent to the function
ScanAPI_CMD_Initialize
. This callback function receives barcode data, status data and error
information.
Configuration of the callback function according to the prototype declaration in
scanapi.h
:
typedef INT (*SCANAPICB)(int, long, long);
This corresponds for example to the following function declaration
int CALLBACK ReceiveFromScanAPICB(int iEvent, long lParam1, long lParam2);
with configuration of the relevant variables
SCANAPICB MyScanAPICB; // Address variable for callback function
MyScanAPICB = (SCANAPICB)ReceiveFromScanAPICB; // Assign address