Typische Aufrufsequenz
Die Methoden, die Sie implementieren müssen, um eine Ink-Erkennung zu erstellen, werden von den Tablet PC-Plattform-APIs und nicht direkt von einer Ink-fähigen Anwendung aufgerufen.
Die folgenden Schritte stellen eine typische Aufrufsequenz für die Implementierung dieser Methoden dar:
- Die DLL wird geladen.
- Ein HRECOGNIZER-Handle wird erstellt.
- Ein HRECOCONTEXT-Handle wird erstellt.
- Erkennungsoptionen und -modi werden für diesen Kontext festgelegt.
- Striche werden den Ink-Daten hinzugefügt.
- Die Eingabe wird beendet.
- Die Ink-Datei wird erkannt.
- Die Erkennungsergebnisse werden zurückgegeben.
- Das HRECOCONTEXT-Handle wird zerstört.
- Das HRECOGNIZER-Handle wird zerstört.
Die aufrufende Sequenz wird auch in der folgenden Codegliederung veranschaulicht:
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);