共用方式為


一般呼叫序列

您必須實作以建立筆跡辨識器的方法是由平板電腦平臺 API 呼叫,而不是由已啟用筆跡的應用程式直接呼叫。

下列步驟代表這些方法實作的典型呼叫順序:

  1. 載入 DLL。
  2. 會建立 HRECOGNIZER 控制碼。
  3. 會建立 HRECOCONTEXT控制碼。
  4. 已為此內容設定辨識器選項和模式。
  5. 筆劃會新增至筆跡資料。
  6. 輸入已結束。
  7. 可辨識筆跡。
  8. 會傳回辨識結果。
  9. HRECOCONTEXT控制碼已終結。
  10. HRECOGNIZER控制碼已終結。

呼叫順序也會在下列程式碼大綱中說明:

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);

辨識器 API

辨識 API 架構