Description
|
Informs the API that a function is
to be used as a callback function for receipt of the specified type(s) of
data. |
|||||||||||||||||||||||||||
Parameters |
The device handle, a context identifier, the required data type(s) which may be ORd together and a pointer to the callback routine. Possible parameters are:
|
|||||||||||||||||||||||||||
Returns |
0 = fail, 1 = OK. |
|||||||||||||||||||||||||||
Notes |
The context value is passed unchanged to the callback function for identification purposes. All functions registered must be unregistered before the program terminates, see calls below. To trap all events, pass a value of 0xFFFF (or &HFFFF for VB) in the aTypes parameter. To get data for all devices pass
device handle 0. Note that underscore prefixes are
omitted in Visual Basic declarations, i.e. _ReadDataTypeXY becomes ReadDataTypeXY. You should always ensure that a
callback for _ReadDataTypeUnload is registered; the driver will invoke
this callback:- 1) During uninstall. 2) When all device instances are deleted from the device manager (explicity or implicitly by the removal of hot pluggable PnP hardware). 3) During Windows shutdown (although this happens so late in the process
as to be irrelevant for practical purposes).
at which time you should
unregister any other callbacks and terminate. |
|||||||||||||||||||||||||||
See also |
Register data callback routine |
|||||||||||||||||||||||||||
|
Unregister data callback routine |
|||||||||||||||||||||||||||
|
Unregister data callback routine context |
Visual C++
Declaration/example
BOOL TBAPI
TBApiRegisterDataCallback(HTBDEVICE aDeviceHandle, unsigned long aContext,
unsigned long aTypes, TB_DATA_CALL aFunc);
// In the following example
CBFunc is called whenever pointer co-ordinates are processed by relative device
1 until TBApiUnregisterDataCallback is called
HTBDEVICE hd =
TBApiGetRelativeDevice(0);
TBApiRegisterDataCallback(hd,0,_ReadDataTypeXY,CBFunc);
...
void TBAPI CBFunc(unsigned
long context, _PointerData* data)
{
char buf[100];
sprintf(buf, "device %d Generated x=0x%x
y=0x%x\n",
(int)data->pd.device,
(int)data->pd.xy->rawx,
(int)data->pd.xy->rawy);
AfxMessageBox(buf);
}
Public
Declare Function TBApiRegisterDataCallback Lib "TBapi" Alias
_DLL_TBApiRegisterDataCallback@16" (ByVal aDeviceHandle As Byte, ByVal
aContext As Long, ByVal aTypes As Long, ByVal aFunc As Long) As Long
Dim dev as byte
dev =
TBApiGetRelativeDevice(0)
TBApiRegisterDataCallback
dev, 0, ReadDataTypeXY, CBFunc
...
Public Sub CBFunc(ByVal
iContext As Long, ByRef pMyData As CoordinateData)
With pMyData
MsgBox "device
& .device & _
generated x=" & .RawX & _
" y=" & .RawY
End With
End Sub