Partager via


Processing User Input (Windows Embedded CE 6.0)

1/6/2010

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

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

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

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 shows how to set the results for 10 boxes at a time, with 5 alternatives for each box.

#define MAX_HWXRESULT   10


HANDLE hMem = GlobalAlloc(GHND, MAX_HWXRESULT * (sizeof(HWXRESULTS) + (5-1) * sizeof(WCHAR)) );
HWXRESULTS * rgBoxR = (HWXRESULTS * ) GlobalLock( hMem);

do
  {
    int iRes = HwxGetResults ( hrc, 5, indx, MAX_HWXRESULT, rgBoxR);
        if( HRCR_ERROR == iRes )
     {
      break;
      }
  if( (0 < iRes ) && (MAX_HWXRESULT > iRes) )
      {
       indx += (UINT) iRes;
      }
  else
     {
// The index is not valid for the memory that was allocated.
// report an error and exit the loop.
     }
}
while (iRes == 10);

After all input, processing, recognition, and output have been completed, destroy the active HRC by calling the HwxDestroy function.

See Also

Concepts

Processing User Input with Alternatives

Other Resources

Recognizing a Hand-drawn Character
Handwriting Recognizer Engine (HWX) Application Development