Click here to Skip to main content
12,882,493 members (27,842 online)
Click here to Skip to main content
Add your own
alternative version


70 bookmarked
Posted 20 Apr 2004


, 25 Apr 2004 CPOL
Rate this:
Please Sign up or sign in to vote.
A CEdit control with a spell checker and thesaurus.

Sample Image - main.jpg


Sometimes, it would be nice to have an edit box with a spell checker and/or thesaurus built in, especially if you use edit boxes to enter longer messages (E.g. for logs, descriptions, IM messages, ...).

While searching the web, I found some free spell checkers, but most of them didn't work on Windows, or missed many language dictionaries. Then I found MySpell which is used by the free OpenOffice suite. It is distributed under a BSD license, which means you can use it in commercial applications. You just have to mention the copyright somewhere in your app.

And since MySpell is used by OpenOffice, there are dictionaries for almost every language available. And those dictionary files are compatible with the ones Mozilla uses.

I found MySpell, I started hacking on extending the CEdit control to make good use of it. Here's what the result looks like:




To use the CSpellEdit control:

  1. Add the files SpellEdit.h, SpellEdit.cpp and all files in the MySpell folder to your project.
  2. Replace all CEdit variables with CSpellEdit (don't forget to #include the SpellEdit.h file).

Since the default context menu of the edit control is replaced (see PJ Arends' article here on how to do that), you might want to translate those strings (default is English). To do that, you can add the following strings to your resource stringtable:


If those strings are not present, then the default English strings will be used.

Also: if no dictionary files are found or set, then the CSpellEdit control will do nothing, i.e. it will be exactly like the normal CEdit control.


CSpellEdit searches for dictionary files at startup automatically. It looks for those files in the same directory as the program is and in the /dic/ subfolder. For example in:

  • c:\program files\myapp\
  • c:\program files\myapp\dic\

Since there could be many dictionary files in those folders, CSpellEdit first checks if there are dictionaries for the current user locale. If those are not found, then it looks for the English dictionaries. Example:

Current user locale is: de_CH
try myapp\de_CH.*
try myapp\dic\de_CH.*
try myapp\de_DE.*
try myapp\dic\de_DE.*
try myapp\en_US.*
try myapp\dic\en_US.*

If you don't want to store the dictionary files in your program's folder, you can set the paths to the dictionary files with the SetDictPaths() and SetThesaurPaths() methods.


26.04.2004 - if found in user32.dll, the default context menu of the edit control is used.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
Switzerland Switzerland

You may also be interested in...

Comments and Discussions

GeneralGPL Dictionary Pin
BoazHarrosh27-Apr-04 21:52
memberBoazHarrosh27-Apr-04 21:52 
SteveKing wrote ...
Note: some of those dictionaries are distributed under GPL, which means you can't pack and install those with your commercial app. But your users can still download and use those dictionaries themselves.

This is not true!

One can and is encouraged to distribute these dictionaries with the application.
Only that:
1) If the dictionary is compiled from Data files using some tools and Make/project files Than all these should be supplied as well. In general the user should have all he needs to be able to change /enhance these dictionaries.
2) Any changes made by the application author should be made available to it's users.
3) The users must be allowed to freely copy and distribute those GPL parts of the application. (Note: this does not mean the user can copy and distribute the all application. Only the Dictionary in this case.)

BSD License in this respect differs from GPL that Privet owner can make changes to Items and does not have to show/give these changes. GPL prevents that.

Free Life & Linux
GeneralRe: GPL Dictionary Pin
SteveKing</font28-Apr-04 3:47
memberSteveKing28-Apr-04 3:47 
GeneralRe: GPL Dictionary Pin
Anonymous18-May-05 2:49
sussAnonymous18-May-05 2:49 
GeneralRe: GPL Dictionary Pin
BoazHarrosh18-May-05 3:57
memberBoazHarrosh18-May-05 3:57 
GeneralRe: GPL Dictionary Pin
m00m0019-May-05 18:36
memberm00m0019-May-05 18:36 
GeneralRe: GPL Dictionary Pin
Ed K4-Jun-05 8:16
memberEd K4-Jun-05 8:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170422.1 | Last Updated 26 Apr 2004
Article Copyright 2004 by SteveKing
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid