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)




(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."

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
Unix Manual Pages
Delphi Examples