Click here to Skip to main content
11,416,787 members (63,679 online)
Click here to Skip to main content

SpellEdit

, 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

Introduction

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:

spellchecker

thesaurus

Usage

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:

  • IDS_SPELLEDIT_UNDO
  • IDS_SPELLEDIT_COPY
  • IDS_SPELLEDIT_CUT
  • IDS_SPELLEDIT_DELETE
  • IDS_SPELLEDIT_PASTE
  • IDS_SPELLEDIT_SELECTALL

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.

Dictionaries

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.

Updates

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

License

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

Share

About the Author

SteveKing
Software Developer
Switzerland Switzerland
---

Comments and Discussions

 
QuestionDebug Assertion Failure! Pin
Member 810351615-May-13 10:55
memberMember 810351615-May-13 10:55 
QuestionCRichEditCtrl Pin
andwan05-Nov-12 1:18
memberandwan05-Nov-12 1:18 
GeneralHTML error Pin
William Winner4-Feb-10 9:04
memberWilliam Winner4-Feb-10 9:04 
GeneralAre there any ports of MySpell Pin
zdacom13-Aug-09 20:39
memberzdacom13-Aug-09 20:39 
QuestionDude the ese wont shoe the red underlines? Pin
mrtutorial0826-Aug-08 7:28
membermrtutorial0826-Aug-08 7:28 
GeneralInteresting Pin
garaber13-Dec-06 6:56
membergaraber13-Dec-06 6:56 
Questionhunspell ? Pin
gogac21-Jun-06 15:09
membergogac21-Jun-06 15:09 
QuestionAnyone got this to compile???? Pin
Tim Hutzler14-Mar-06 8:29
memberTim Hutzler14-Mar-06 8:29 
GeneralPermission to use SpellEdit Pin
keith27033-Jan-06 6:21
memberkeith27033-Jan-06 6:21 
QuestionMySpell Pin
Hesham Desouky28-Sep-05 10:07
memberHesham Desouky28-Sep-05 10:07 
GeneralAdding new words to the dictionary files Pin
keith270319-May-05 1:17
memberkeith270319-May-05 1:17 
GeneralRe: Adding new words to the dictionary files Pin
m00m0019-May-05 17:16
memberm00m0019-May-05 17:16 
Generalmemory leak when performing NGRAM suggestion Pin
m00m0016-May-05 20:11
memberm00m0016-May-05 20:11 
Generalcode can not compiled by VS.Net 2002 Pin
m00m0010-May-05 19:55
memberm00m0010-May-05 19:55 
GeneralRe: code can not compiled by VS.Net 2002, nevermind Pin
Anonymous11-May-05 2:34
sussAnonymous11-May-05 2:34 
GeneralRe: code can not compiled by VS.Net 2002, nevermind Pin
m. bergman16-Jun-05 15:27
memberm. bergman16-Jun-05 15:27 
Generalhelp Pin
rjnl21-Mar-05 10:12
memberrjnl21-Mar-05 10:12 
GeneralRe: help Pin
Ed K1-May-05 15:30
memberEd K1-May-05 15:30 
GeneralRe: help Pin
rjnl2-May-05 14:39
memberrjnl2-May-05 14:39 
Generalhelp Pin
rjnl21-Mar-05 10:11
memberrjnl21-Mar-05 10:11 
GeneralPatch Pin
marren1-May-04 3:48
membermarren1-May-04 3:48 
GeneralGPL Dictionary Pin
BoazHarrosh27-Apr-04 22:52
memberBoazHarrosh27-Apr-04 22:52 
GeneralRe: GPL Dictionary Pin
SteveKing28-Apr-04 4:47
memberSteveKing28-Apr-04 4:47 
GeneralRe: GPL Dictionary Pin
Anonymous18-May-05 3:49
sussAnonymous18-May-05 3:49 
GeneralRe: GPL Dictionary Pin
BoazHarrosh18-May-05 4:57
memberBoazHarrosh18-May-05 4:57 
GeneralRe: GPL Dictionary Pin
m00m0019-May-05 19:36
memberm00m0019-May-05 19:36 
GeneralRe: GPL Dictionary Pin
Ed K4-Jun-05 9:16
memberEd K4-Jun-05 9:16 
GeneralThesaurus Problems Pin
mollweide27-Apr-04 5:15
membermollweide27-Apr-04 5:15 
GeneralRe: Thesaurus Problems Pin
SteveKing27-Apr-04 7:28
memberSteveKing27-Apr-04 7:28 
GeneralRe: Thesaurus Problems Pin
uspoeri26-May-04 1:55
memberuspoeri26-May-04 1:55 
GeneralRe: Thesaurus Problems Pin
SteveKing26-May-04 2:59
memberSteveKing26-May-04 2:59 
GeneralRe: Thesaurus Problems Pin
elza30-Dec-04 2:11
memberelza30-Dec-04 2:11 
GeneralRe: Thesaurus Problems Pin
elza2-Jan-05 1:45
memberelza2-Jan-05 1:45 
GeneralRe: Thesaurus Problems Pin
SteveKing10-Jan-06 8:05
memberSteveKing10-Jan-06 8:05 
Generalabout edit control menu Pin
Paolo Messina22-Apr-04 1:04
memberPaolo Messina22-Apr-04 1:04 
GeneralRe: about edit control menu Pin
SteveKing22-Apr-04 1:45
memberSteveKing22-Apr-04 1:45 
On my XP system, it is the ID 1 too (as on your system).
Now, if we could gather the ID's of that resource on all possible system, then I would be happy to use that resource and append the custom menu to it than to just replace it.
But as long as I can't verify that it is in fact the ID No. 1 in user32.dll on all systems, I'd rather replace it.
GeneralRe: about edit control menu Pin
Paolo Messina23-Apr-04 14:32
memberPaolo Messina23-Apr-04 14:32 
GeneralRe: about edit control menu Pin
Paolo Messina23-Apr-04 14:27
memberPaolo Messina23-Apr-04 14:27 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150427.4 | Last Updated 26 Apr 2004
Article Copyright 2004 by SteveKing
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid