RichEdit Spell Checking, Autocorrection and Prediction
RichEdit has provided support for client spell checking (TOM object model and temporary character formatting—see tomApplyTmp) and autocorrect (see EM_SETAUTOCORRECTPROC) for many years. But it has been the RichEdit client’s responsibility to access the spell-checking and autocorrection components, except for the built-in math autocorrect option. For clients like OneNote and Outlook, such a responsibility is a small part of the app. But for little programs, accessing proofing components can be arduous. This would be especially true for small apps written using Windows RT.
Accordingly, RichEdit 8 was enhanced to be able to access the Windows 8 spell-checking and autocorrection components directly. The traditional Windows client using msftedit.dll on Windows 8 enables this functionality by sending an EM_SETLANGOPTIONS message with one or more of the options IMF_SPELLCHECKING, IMF_TKBAUTOCORRECTION, and IMF_TKBPREDICTION. The client also needs to enable the Text Foundation Services by sending an EM_SETEDITSTYLE message with the flags SES_USECTF, SES_CTFALLOWEMBED, SES_CTFALLOWSMARTTAG, and SES_CTFALLOWPROOFING.
In the Windows RT RichEditBox, which uses a rich-text RichEdit control, spell checking is enabled by default. The Windows RT TextBox, which uses a plain-text RichEdit control, also can have spell checking, but spell checking is disabled by default. You can change the setting using the Properties pane. Bogdan Radakovic, a developer in Windows 8, integrated the proofing features into RichEdit 8.
To try the proofing features out, I fired up Visual Studio 12 and created a new C++ project for the “Windows Store” using the “Blank App (XAML)” template. I dragged a RichEditBox from the Toolbox into the design view for the MainPage.xaml file. The RichEditBox starts out really small, so I expanded it to a reasonable size for typing text and built and ran the project. To my delight, my typing was proofed and autocorrected very nicely! The keyboard language is used to select the current proofing tools. So I switched to a German keyboard and typed in some text. Sure enough, the German proofing tools are used, which is very cool (I included the German proofing tools in my US Windows 8 installation). But if I type German using an English keyboard, I see lots of words with red-squiggle underlines. The proofing tools do not attempt to guess the language on the fly. For most people, this is a reasonable approach, especially since language detection isn’t infallible. Possibly in the next version, language detection will be offered as an option.