Receiving Spelling Suggestions from the Spelling Checker

Once you have determined that a word in the input buffer of SPLBUFFER is misspelled, call SplSuggest. Like SplReplace, SplSuggest returns one or more suggestions for a misspelled word. However, SplReplace can return up to eight possible suggestions.

In addition to returning spelling suggestions, SplSuggest can also score the suggestions. A score is a number that indicates how much a replacement word differs from the original misspelled word. A low score indicates that the misspelled word was changed slightly, while a high score indicates that the word was changed a great deal. You can use suggestion scores in your application to exclude some words from the list of alternatives.

Once SplSuggest finishes processing, you can access the output buffer through the aspl member of SPLBUFFER. The aspl member is an array of SPLSUGGEST structures. The first member of a SPLSUGGEST structure points to a word in the output buffer. If you chose to use scores, the second member contains a score for that word.

    To receive spelling suggestions from the spelling checker

  1. If you want to use scores, set SPL_SCORE_SUGGESTIONS with SplSetOptions.
  2. Set the size and location of the output buffer with the cwcOut and pwszOut parameters of SPLBUFFER.

    This SPLBUFFER is the same structure returned by your original call to SplCheck.

  3. Set the aspl, cwcUsed, and cspl parameters of the SPLBUFFER structure to receive the appropriate data.

    SplSuggest returns an array of pointers to the output buffer in aspl, the size of the output buffer used in cwcUsed, and the number of suggestions in cspl.

  4. Call SplSuggest.