Wintertree Software Inc.

WSpell ActiveX Spell Checker for MFC

Home Site index Contact us Catalog Shopping Cart Products Support Search

Add a spell checker to your MFC applications with WSpell

You are here: Home > Add a spell checker to your applications > MFC > WSpell

WSpell provides everything you need to add a full spell check capability to your 32-bit MFC applications. Click here to find out more about WSpell.

Click on a topic below to find out more about how WSpell works with your MFC applications:


How to spell check a CEdit or CRichEdit control

Many MFC applications let their users enter text via a CEdit or CRichEdit control in a dialog. If this is how your application works, you can add a spell checker in minutes using these simple steps:

  1. Set the No Hide Selection property of the CEdit or CRichEdit control, or set the ES_NOHIDESEL style when you create the control. This lets WSpell highlight any misspelled words found.

  2. Add a "Spell check" button or menu item to your form.
  3. In the event handler for your "Spell check" button or menu item, set WSpell's TextControlHWnd property to the m_hWnd property of your CEdit or CRichEdit control, and call WSpell's Start method.

That's all there is to it! When the "Spell check" button or menu item is pressed, WSpell will check the spelling of words in the text control. If a misspelled word is found, WSpell will pop up a dialog the user can interact with to dispose of the misspelling. The misspelled word will be highlighted in the control. The dialog shows suggested replacements for the misspelled word. If the user makes a correction, the text box will be updated automatically.

Spell check dialog


How to check spelling "as you type"

You may want to give your users immediate feedback on spelling errors, to report misspellings as soon as they occur. This feature is used in Microsoft Office. Your users are probably already familiar with the "as you type" spell checker feature and may demand it in your product. Including it will give your product a competitive advantage.

"As you type" spell checking is easy with WSpell! Just call the CheckBackground function, passing the m_hWnd property of a CRichEditCtrl. WSpell will monitor the user's typing in the background, and will change any misspelled words to red. Corrected words are automatically changed back to black. Right-clicking the mouse over a misspelled word pops up a context menu containing suggested replacements.

"As you type" spell checking. The context menu shows suggested replacements for misspelled words.


How to spell check strings

Spell check dialog showing context display.

The text you want to spell check may not be entered by the user -- it may be read from a disk file or database, or obtained from data structures within your MFC application.

WSpell can check words contained in strings interactively or not interactively.

To check a string interactively, just set WSpell's Text property to the string's value, then call the Start method. The string can contain a single word or an entire book. WSpell will check the spelling of words in the string. If a misspelled word is found, WSpell will pop up a dialog the user can interact with to dispose of the problem. The dialog shows suggested replacements for the misspelled word. If the user makes a correction, the string will be updated automatically. WSpell can even optionally show the string's contents in a text box attached to the dialog so the user can see the misspelled words in context.

You can check strings non-interactively in two ways. First, you can quickly determine if a single word is correctly spelled or not by passing it to WSpell's TestWord method. TestWord returns TRUE if the word is correctly spelled and FALSE otherwise.

Second, you can check a string containing one or more words in three simple steps:

  1. Set the string's value to WSpell's Text property.

  2. Set WSpell's ShowDialog property to False. This disables display of the built-in spell check dialog.
  3. Call WSpell's Start method.
  4. Catch any MisspelledWord events fired by WSpell. When the event is fired, WSpell's MisspelledWord property will contain the problem word, and the WordOffset property will contain the position of the word in the string. Your MFC application can obtain a list of suggested replacements for the misspelled word from the Suggest method.


Home Site index Contact us Catalog Shopping Cart Products Support Search


Copyright © 2015 Wintertree Software Inc.