Sequenza di chiamata tipica
I metodi che è necessario implementare per creare un riconoscimento input penna vengono chiamati dalle API Tablet PC Platform e non direttamente da un'applicazione abilitata per l'input penna.
I passaggi seguenti rappresentano una sequenza di chiamata tipica per l'implementazione di questi metodi:
- La DLL viene caricata.
- Viene creato un handle di HRECOGNIZER.
- Viene creato un handle di HRECOCONTEXT.
- Le opzioni e le modalità di riconoscimento sono impostate per questo contesto.
- I tratti vengono aggiunti ai dati input penna.
- L'input è terminato.
- L'input penna viene riconosciuto.
- Vengono restituiti i risultati del riconoscimento.
- L'handle di HRECOCONTEXT viene eliminato definitivamente.
- L'handle di HRECOGNIZER viene eliminato definitivamente.
La sequenza chiamante è illustrata anche nella struttura del codice seguente:
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);
Argomenti correlati