Sentry Spelling Checker Engine - Support |
Home |
You are here: Home > Support > Sentry Spelling Checker Engine > 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:
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).
- The control provides a mechanism to select text using an offset and a length.
- The control provides a mechanism to replace the selected text with new text.
- 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.
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.
Copyright © 2015 Wintertree Software Inc.