The Components- TAddictSpell
This component is what controls spell checking. It manages controls which do live-spelling (wavy red underlines), manages loaded dictionaries, and runs the spelling check dialog.
There should be exactly once instance of this component in your application. If your application only utilizes spell checking from a single form, the recommended position is on that form. If spell checking is utilized throughout your application, the recommended location is on a shared data module that's created prior to other form resources.
- TAddictSpellEdit, TAddictSpellMemo, TAddictSpellRichEdit
TAddictSpellDBEdit, TAddictSpellDBMemo, TAddictSpellDBRichEdit
These components provide live-spelling and auto-correct as you type services. These controls all automatically hook up to the TAddictSpell component residing in your application. Various attributes about these controls (such as the underline color) are all jointly configured through properties available from TAddictSpell.
Dictionaries and Persistence- Language Dictionaries
Language dictionaries (sometimes called Main Dictionaries) are files that store a highly compressed pre-compiled list of words that are considered spelled correctly for any particular language. By default, Addict only ships with 'American.adm', but many more dictionaries are available on the dictionaries page. These pre-compiled dictionary files all end in an ADM extension.
- Custom Dictionaries
Custom dictionaries are files that are dynamically updated during a spelling check. These dictionaries can represent correctly spelled words (commonly called 'Ignore' words), auto-correct pairs, and excluded words (sometimes called 'Forbidden' words). These dictionaries all end in an ADU extension.
The most common usage of custom dictionaries is to allow the user of your application to add words that they consider spelled correct during a spelling check. The typical application setup is configured such that each distinct user of your application will each have their own custom dictionary file that are each updated independently of one another.
Custom dictionaries can also be supplied to supplement a spelling check as well. A good example of this is the AutoCorrect.adu dictionary that we ship with Addict. This is a custom dictionary that has a number of common English auto-corrections.
- Learning Dictionaries
These dictionaries are automatically created by the spelling checker and are used to track a user's history of spelling corrections so that the spelling checker can improve the order of the suggestions presented to the user over time. These dictionaries have an ADL extension.
This is an optional feature and creation of these dictionaries can be disabled by setting the SuggestionsLearning property to false.
- Configuration Data
The spelling checker provides an extensive configuration UI for a user to customize their experience as desired. As a result, a persistent store is needed for storing the various available options and selected dictionaries. Where this persistent store is saved is controlled by the ConfigStorage property. It may be directed to the registry (the default), to a particular file, or to a callback (OnConfigReadString and OnConfigWriteString) provided by your application depending upon the value of ConfigStorage.
The BasicsFor providing a basic spelling check, most applications will ship American.adm and AutoCorrect.adu with their application. By default Addict will pick up any dictionaries that are in the same directory as the EXE is placed. You can place them elsewhere if you like; just change the ConfigDictionaryDir property to include the new location as well.
The default Addict configuration will pick these dictionaries up and use them by default (see the ConfigDefautXXX properties to control the initial configuration).
To perform a spelling check with most controls simply use the CheckWinControl method. This method takes two parameters; the control being checked and what to check of the control (most people will use ctAll)... e.g.:
Code:
AddictSpell1.CheckWinControl( Memo1, ctAll );
To perform a spelling check with a 3rd party control that isn't based on the standard Microsoft edit or rich edit controls, please see the appropriate demo on the
3rd party page.
To expose the configuration UI to a user, simply use the Setup method.
Code:
AddictSpell1.Setup;
This routine shows the standard Addict configuration dialog and allows the user to control various aspects of their spelling check. All settings in this dialog are loaded from the configuration data mentioned above. If no configuration data exists (first run only) then all settings are loaded from the various ConfigDefaultXXX properties.
Live-spelling and auto-correct are already on in the default configuration, so all you really need to do to see them is type in your edit control if you're using one of Addict's supplied edit controls.
Addict is also capable of performing live-spelling for standard Microsoft edit, memo and rich edit controls. This includes many 3rd party components that are built on top of these controls. To enable live-spelling in these controls, you need to use the AddControl and RemoveControl methods.
Code:
AddictSpell1.AddControl( Memo1 );
...
AddictSpell1.RemoveControl( Memo1 );
AddControl should be called where you wish to begin live-spelling and RemoveControl should be called when live-spelling should cease.