Sequência de chamadas típica
Os métodos que você deve implementar para criar um reconhecedor de tinta são chamados pelas APIs da Plataforma tablet pc e não diretamente por um aplicativo habilitado para tinta.
As etapas a seguir representam uma sequência de chamadas típica para a implementação desses métodos:
- A DLL é carregada.
- Um identificador HRECOGNIZER é criado.
- Um identificador HRECOCONTEXT é criado.
- As opções e os modos do reconhecedor são definidos para esse contexto.
- Os traços são adicionados aos dados de tinta.
- A entrada foi encerrada.
- A tinta é reconhecida.
- Os resultados do reconhecimento são retornados.
- O identificador HRECOCONTEXT é destruído.
- O identificador HRECOGNIZER é destruído.
A sequência de chamadas também é ilustrada na seguinte estrutura de tópicos de código:
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);
Tópicos relacionados