Wintertree Software Inc.

Sentry Spelling Checker Engine - Support

Home Site index Contact us Catalog Shopping Cart Products Support Search

You are here: Home > Support > Sentry Spelling Checker Engine > Using SSCE_CheckCtrlDlg with a 3rd-party edit control

Using SSCE_CheckCtrlDlg with a 3rd-party edit control

Product: Sentry Spelling Checker Engine Windows SDK

Version: Any

Problem: When you pass the handle of a 3rd-party edit control to SSCE_CheckCtrlDlg, nothing happens, or the results aren't as you expect.

Solution: SSCE_CheckCtrlDlg communicates with the control being checked through standard messages such as WM_GETTEXTLENGTH and WM_GETTEXT. This technique works with standard text and rich-text boxes. Unfortunately, many 3rd-party controls do not respond to these messages, or they respond in non-standard ways. The following technique can be used to check the words contained by a control provided the following is true:

  1. The control provides some way of getting the unformatted text as a simple string of ASCII or ANSI characters. Sometimes this is done through the control's Text property. If the control doesn't provide a direct way of getting the unformatted text, one method that may work is to copy all the text to the clipboard, then access the clipboard contexts as text (i.e., using the CF_TEXT format).

  2. The control provides a mechanism to select text using an offset and a length.
  3. The control provides a mechanism to replace the selected text with new text.
  4. Formatting (e.g., font changes) applies to entire words only and not to partial words. For example, no font changes occur in the middle of a word.

If all the above conditions are met, the following technique can be used to check the text contained by a control, highlight misspelled words, and correct misspellings.

Note that this technique involves calls to Sentry's Core API. Wherever a session id (sid) is needed by a Core API function, call SSCE_GetSid to obtain the session id used by the Sentry DLL. See the Sentry Programmer's Guide for detailed descriptions of each function.

Also note that a demonstration of this technique is available in the "Check 3rd Party" demo in the Sentry example programs.

  1. Extract the unformatted text from the control, and call SSCE_OpenBlock to open a block containing the text. Be sure to allocate room for growth.

  2. Call SSCE_CheckBlock to check the spelling of words in the block. Call SSCE_CheckBlock in a loop until it returns SSCE_END_OF_BLOCK_RSLT.
  3. When SSCE_CheckBlock detects a misspelled word, call SSCE_GetBlockInfo to obtain the offset of the word (the block's cursor position). Tell the text control to select (highlight) the number of characters indicated by the length of the misspelled word, starting at the word's offset. Call SSCE_CheckBlockDlg to check the misspelled word; this will give the user the opportunity to look up suggestions, enter a correction, etc. When SSCE_CheckBlockDlg returns, check if the user changed the word (compare it with the misspelled word). If the user changed the word, tell the text control to replace the selected text with the changed word, and call SSCE_ReplaceBlockWord to replace the word in the block. Call SSCE_NextBlockWord to advance to the next word.
  4. When SSCE_CheckBlock reports that the end of the block has been reached, call SSCE_CloseBlock.


Home Site index Contact us Catalog Shopping Cart Products Support Search


Copyright © 2015 Wintertree Software Inc.