Processing User Input

To begin each input recognition session with a clean HRC, use the context from a pre-established HRC as a template. Each time you need a new HRC, pass the handle of the previous HRC object, excluding any previous ink data, to the recognition engine. This enables your application to save processing time by not having to recreate common HRC parameters that are used repeatedly in your application, such as GUIDE structures and alphabet codes.

The character recognition sequence begins when the input panel IM sends a call to HwxInput. This function adds ink to the HRC object to provide the STROKEINFO structure with the count of stylus stroke points that are generated. HwxProcess passes the HRC to the recognition engine where the stroke data is processed, based on predetermined character recognition parameters. When a user finishes entering stroke data, your application calls HwxEndInput to tell the recognition engine that no further ink will be added to the HRC.

To improve the performance of the recognition process, pass the context for the previous character to the recognition engine through HwxSetContext. If this function is not called, the recognition engine will assume that no previous context is available. HwxSetContext is called before HwxProcess. HwxProcess processes the ink received by the HRC to perform the recognition. Full character recognition occurs only after HwxEndInput is called. Results of the recognition are returned by HwxGetResults.

HwxGetResults simplifies the task of recognizing characters and glyphs that are drawn within the boundaries of the defined box by responding with character alternatives on a per-box basis in one call. The following code example sets the results for 10 boxes at a time, with 5 alternatives for each box.

HANDLE hMem = GlobalAlloc( GHND, 10 * (sizeof( BOXRESULTS )
         + (5-1) * sizeof( SYV )) );
LPBOXRESULTS rgBoxR = (LPBOXRESULTS)GlobalLock( hMem );
UINT indx = 0;
Do 
{
   int iRes = HwxGetResults( hrc, 5, indx, 10, rgBoxR); 
       . 
       .        // Check for errors and use rgBoxR 
       . 
   indx += (UINT)iRes; 
} 
while (iRes == 10);

Once all input, processing, recognition, and output has been completed, destroy the active HRC with the HwxDestroy function.