There’s been a lot of buzz about the Windows 8 Consumer Preview and it is really exciting. One particularly exciting thing missing in the buzz is that Windows 8 contains a new RichEdit! Since the new version is now publically documented on MSDN, I can write about it. I found the public documentation by Binging for ITextRange2, one of the TOM2 interfaces introduced in RichEdit 6.0. As you can imagine, I’ve been dying to write about RichEdit 8 in Windows 8 for quite a while. There’s so much to say that there will be several posts on it.
In contrast, Windows 7 has RichEdit 4.1 which shipped with Windows XP SP1 back in 2003 (the Windows 7 version does have a few upgrades for new languages and security improvements). The new RichEdit is housed in the msftedit.dll. The older RichEdit 3.0 (riched20.dll) that also ships with Windows 8 is the same as that for previous versions of Windows aside from possible security fixes. We keep that riched20.dll around so that we don’t break really old applications that depend on it.
For developers, having the documentation for the TOM2 text object model, up-to-date messages, and the brand new WinRT text object model should be very useful. In previous posts I’ve described features added to RichEdit version 5 through 7 for Microsoft Office and people have commented that it’s kind of disheartening to read about these cool features and not be able to use them for lack of documentation. Well now they’re documented and all you need is Windows 8 to use them.
There are two key differences between the TOM2 interfaces that ship with RichEdit 8 and those in RichEdit 6 and 7: 1) ITextDocument2 is somewhat different and 2) ITextRange2::InsertImage() is new and is accessed through the last entry in the interface table. These changes might complicate things a bit if you want to use the TOM2 documentation with the Office 2007 or 2010 RichEdit. The RichEdit that ships with the next version of Office will have the same TOM2 interfaces as the Windows 8 RichEdit.
The other thing I’d like to point out in this post is that the new RichEdit supports math editing and display! This capability is disabled by default; to enable it, send a message EM_SETEDITSTYLEEX with wparam = 0 and lparam = SES_EX_NOMATH (defined in the new richedit.h). The new RichEdit doesn’t support the math paragraph. There was only so much we could get in. You can paste math text from Word into RichEdit 8 and vice versa since both programs support Math RTF. They also both support MathML and OMML
If you’re programmatically oriented, you might want to check out ITextRange2::BuildUpMath(). This function can do many math text manipulations, most notably the one converting the math linear format into the built-up (Professional) format. The exported math functions MathBuildUp and MathBuildDown can be used by any application that implements the requisite callback interfaces. Word, PowerPoint, and RichEdit itself call these functions to build math up and down, respectively.
If you find problems with RichEdit 8 or with the documentation, please let me know. More posts to come, e.g., on the nested table model, DWrite/D2D operation, native spell checking and autocorrect, touch, native image support, accessibility …! This is the biggest RichEdit upgrade ever.