Wintertree Software Inc.

WSpell ActiveX Spelling Checker

Home Site index Contact us Catalog Shopping Cart Products Support Search

You are here: Home > Support > WSpell > How to programmatically recheck text marked during background checking


How to programmatically recheck text marked during background checking

Applies to: Version 5.15 and later

Problem: During background checking, misspelled words will be marked. Later, if the spelling status of certain words changes (for example, if some of the words are added to a user dictionary by the calling application), the words will remain marked. A mechanism is needed to recheck the words so words that are now considered correct will be unmarked.

A similar problem can arise if an application uses a combination of background and interactive (dialog based) user interfaces. Words marked as misspelled during background checking are not automatically unmarked if they are corrected by clicking the "Change" button in WSpell's built-in spelling dialog box.

Discussion: WSpell background checking feature works by examining the text contained by a control when the user types or edits the text. Changes not made by the user, or changes that affect the spelling status of words, are normally part of the background checking mechanism and therefore have no effect on marked or unmarked words. The CheckBackgroundRecheck method doesn't help here, because it will mark words found to be misspelled, but will not unmark words which are now correct.

Solution: WSpell will recheck words when the caret (insertion point) passes through them. The caret can be changed via the SelStart and SelLength properties, or by sending an EM_SETSEL message to the monitored control. If the caret is advanced from the first to the last character, and CheckBackgroundNotify is called each time the caret is incremented, WSpell will re-examine the spelling status of each word. Following is some sample VB code to accomplish this:

    Dim i As Integer
Dim s As String
    s = RichTextBox1.Text
For i = 0 To Len(s) - 1
RichTextBox1.SelStart = i
RichTextBox1.SelLength = 0
Call WSpell1.CheckBackgroundNotify(RichTextBox1.hWnd, _
True, False, False, False, vbRed)
Next

The code above would be called after some change was made that might affect the spelling status of text in the monitored control: New words were added to a user dictionary, or the control's contents were interactively checked by WSpell's built-in dialog box, for example.


Home Site index Contact us Catalog Shopping Cart Products Support Search


Copyright © 2015 Wintertree Software Inc.