Typical Calling Sequence

The methods you must implement to create an ink recognizer are called by the Tablet PC Platform APIs and not directly by an ink-enabled application.

The following steps represent a typical calling sequence for the implementation of these methods:

  1. The DLL is loaded.
  2. An HRECOGNIZER handle is created.
  3. An HRECOCONTEXT handle is created.
  4. Recognizer options and modes are set for this context.
  5. Strokes are added to the ink data.
  6. Input is ended.
  7. The ink is recognized.
  8. The recognition results are returned.
  9. The HRECOCONTEXT handle is destroyed.
  10. The HRECOGNIZER handle is destroyed.

The calling sequence is also illustrated in the following code outline:

CreateRecognizer(CLSID, &hrec);
while (more pieces of ink to recognize ... )
{
  // Create a context, once per piece of ink to be recognized
  hrc = CreateContext(hrec, &hrc);

  // Functions to set up options and modes for this context
  SetGuide(hrc, pGuide, 0);
  SetFactoid(hrc, 5, PHONE); // only if in application with forms
  SetFlags(hrc, RECOFLAG_WORDMODE); // rare, only if wanting word mode, no out-of-dictionary, or single segmentation
  SetWordList(hrc, hwl);

  // Adding all the strokes in this piece of ink
  while (more strokes ... )
  {
    AddStroke(hrc, NULL, 800, pPacket, pXForm);  // one call per stroke
  }
  EndInkInput(hrc);

  // This gets the ink recognized
  Process(hrc);

  // If this is a simple application, it calls this for a simple answer
  GetBestResultString(hrc, length, buffer);

  // If this is a complex application, it calls this for a complete answer
  GetLatticePtr(hrc, &pLattice);

  // Destroy the context
  DestroyContext(hrc);
}
// Called just before the application shuts down
DestroyRecognizer(hrec);

Recognizer APIs

Recognition API Architecture