|
Getting Results from the RCRESULT Structure
Note The RCRESULT structure is supported only for backward compatibility. It may not exist in
future versions of the Pen API. Applications should obtain recognition results
through the API functions described in this chapter, rather than from an RCRESULT structure.
The RCRESULT structure applies only when an application calls either of the version 1.0
recognition functions, Recognize or RecognizeData. In this case, the system sends a WM_RCRESULT message to the application. The wParam of this message contains a REC_ submessage that indicates why recognition
ended. The lParam of WM_RCRESULT points to an RCRESULT structure, which contains all the results of the recognition.
An application can retrieve from the RCRESULT structure all the recognizer's guesses by walking through the list, called
the symbol graph, contained in the RCRESULT structure.
The RCRESULT structure identifies the recognizer's "best guess," which is the guess in
which the recognizer places the most confidence. With this information, an
application can conveniently retrieve an ASCII string of the best guess by calling SymbolToCharacter:
char szBestGuess[MAX_CHAR]; // ASCII string of best guess
.
.
.
switch (wMsg)
{
case WM_RCRESULT:
SymbolToCharacter(
(LPSYV) ((LPRCRESULT)lparam)->lpsyv, // Symbol string
MAX_CHAR, // Maximum length
(LPSTR) szBestGuess, // Buffer for ASCII
NULL ); // Don't need count
Compare the above call to SymbolToCharacter with the previous example. Here, the second argument represents a maximum,
rather than the actual length of the symbol string, which is the value
(int) ((LPRCRESULT)lparam)->cSyv
By specifying the length of the buffer that receives the ASCII text, the
second argument sets a cap on the number of symbols SymbolToCharacter will convert. This prevents the function from overflowing the szBestGuess buffer if the length of the symbol string happens to be larger than MAX_CHAR. SymbolToCharacter returns when it encounters SYV_NULL at the end of the symbol string or when
it converts MAX_CHAR symbols, whichever occurs first.
An application that calls Recognize or RecognizeData must be prepared to receive WM_RCRESULT messages before calling either
function. This is because the recognizer dispatches all WM_RCRESULT messages
associated with a particular recognition event before Recognize or RecognizeData returns.
Version 2.0 of the Pen API provides, through function calls, all the
information contained in an RCRESULT structure. An application need not examine the structure at all. RCRESULT is a product of recognition, and is therefore of more interest to the
recognizer developer than the application developer. Consequently, it is described in
more detail in Chapter 8, "Writing a Recognizer."
Related Links
Software for Delphi and C++ Builder developers
Software for Visual Studio .NET developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET
More Online Helps
Win32 Programmer's Reference (win32.hlp)
Win32 Multimedia Programmer's Reference (mmedia.hlp)
OLE Programmer's Reference (ole.hlp)
Microsoft Windows Sockets 2 Reference (sock2.hlp)
Microsoft Windows Telephony API (TAPI) Programmer's Reference (tapi.hlp)
Unix Manual Pages
|