MIL_ID FontContextOcrId, | //in |
MIL_INT HookType, | //in |
MIL_OCR_HOOK_FUNCTION_PTR HookHandlerPtr, | //in |
void *UserDataPtr | //in |
This function allows you to attach or detach a user-defined function to an event when the specified font is used. A type of event to which a user-defined function can be hooked is string validation. This would immediately follow a read or verify operation. When this type of event occurs, the MocrReadString() or MocrVerifyString() function will call the hooked function one or many times during the operation to validate each string after it is read but before being written to the OCR result buffer. This function allows you to impose global string constraints, and can be used to implement custom checksum functions or to reject strings that would have otherwise met the character constraints imposed.
Note that a function hooked to an event executes on a distinct thread. This permits the functions to run asynchronously from the operation that fired the event and from functions hooked to another event.
Hooked functions should not take longer to execute than the period in which two of their associated events can occur. You cannot determine the instance of the event that fired the function, and even if this were possible, this information would generally not be very useful. Typically, a hooked function performs the minimum number of operations required and, if necessary, performs longer processes by launching other threads.
Specifies the event type. This parameter can be set to the following value:
For specifying the event
type
|
|||||||||||||||||||||||||||||||||||||||
Value | Description
|
||||||||||||||||||||||||||||||||||||||
M_STRING_VALIDATION + |
Specifies the character string to be validated. (more details...) |
You must add the following value to the above-mentioned value to specify to unhook the event that was hooked to the function.
For the HookType parameter to unhook the
function
|
|||||||||||||||||||||||||||||||||||||||
Combination value | Description
|
||||||||||||||||||||||||||||||||||||||
M_UNHOOK |
Unhooks the function that was hooked to the event. |
Specifies the address of the function that should be called when the event occurs.
The hook handler function, pointed to by HookHandlerPtr, must be declared as follows:
Specifies the type of event hooked.
Points to the string to validate.
Specifies the user data pointer passed to MocrHookFunction().
The value returned by the hook function must contain the validity status: either M_TRUE or M_FALSE. Note that, MFTYPE and MIL_OCR_HOOK_FUNCTION_PTR are reserved MIL predefined types for functions and data pointers.
Specifies the address of the user data that you want to make available to the hook-handler function. This address is passed to the hook-handler function, through its UserDataPtr parameter, when the specified event occurs. Set this parameter to M_NULL if the UserDataPtr is not required.
Header | Include mil.h. |
Library | Use mil.lib; milocr.lib. |
DLL | Requires mil.dll; milocr.dll. |