Udostępnij za pośrednictwem


RichEdit 8.0 Preview

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.

Comments

  • Anonymous
    March 03, 2012
    Wow!  That's nice!

  • Anonymous
    March 14, 2012
    That's really great! Murray, could you please explain how to use ITextDocument2 if QueryInterface returns E_NOINTERFACE. I have the latest tom.h from the Visual Studio 11 Beta package, the GUID seems to be correct. I think that the interface is not registered in my system (Win Vista). How can I register TOM2 interfaces? And what operating system can I have except Windows 8? Thank you very much!

  • Anonymous
    March 16, 2012
    It is very interesting. Will this upgrade of Richedit impact somehow the Wordpad in Windows 8? E.g. the extension of Wordpad features?

  • Anonymous
    March 20, 2012
    Dear Murray, Is there any way to get ITextDocument2 interface in Windows prior to Windows 8? This interface is not registered but the library riched20.dll shipped with MS Office contains it. I load this library, then I create RichEdit60W window and obtain IRichEditOle interface via EM_GETOLEINTERFACE message. But querying for interface ITextDocument2 fails. Now I use headers and documentation of TOM2. Unfortunately, your detailed blog "RichEdit Versions 1.0 through 3.0" covers only 1st version of TOM interfaces. As I discovered recently, riched20.dll from Office is a COM type library, and in Windows prior to 8 it's not registered. Unfortunately I haven't enough knowledge and experience in COM programming to obtain ITextDocument2, ITextRange2 interfaces directly from this dll. Could you help me or just direct to the solution of my problem. It is exactly the case when I want to use "TOM2 documentation with the Office 2007 or 2010 RichEdit". I would be glad to any way of using ITextDocument2 (in windowed/windowless RichEdit control) in Windows Vista/ Windows 7 since Windows 8 is not finally released yet. Thank you and sorry for (maybe) annoying questions. This information is very important for me and others, I suppose.

  • Anonymous
    May 02, 2012
    The comment has been removed

  • Anonymous
    August 05, 2012
    What version of RichEdit is shipped with Office 2013 Consumer Preview? Is it also RichEdit 8? Thank you.

  • Anonymous
    April 11, 2013
    SendMessage(hWnd,EM_SETEDITSTYLEEX,0,SES_EX_NOMATH ) does not work in Windows8 RTM. Is there other way to enable math for RichEdit?

  • Anonymous
    July 11, 2013
    Dear Murray, Thank you for your posts. I have the same problem with SendMessage(hWnd,EM_SETEDITSTYLEEX,0,SES_EX_NOMATH ). I'm using Windows 8 and msftedit.dll is loaded, but SES_EX_NOMATH does not change. The other flags can be changed, but this one - no. May be we must do something else before this step to allow entering a math zone? Sincerely, Ivan Manuylovich

  • Anonymous
    July 11, 2013
    Unfortunately math is disabled in the Windows 8 RichEdit. The Windows team didn't have enough time to test it, although it has been tested thoroughly by the RichEdit team. So the SES_EX_NOMATH option does nothing.

  • Anonymous
    July 11, 2013
    The comment has been removed

  • Anonymous
    July 11, 2013
    Thank you for your answer. It's a pity! Do we have a hope that Windows 8.1 will allow math editing in RichEdit? Especially because everything is contained in msftedit.dll and even we can see documentation in MSDN. And also Visual Studio 2013 Preview defines a flag SES_EX_NOMATH. Sincerely, Ivan Manuylovich

  • Anonymous
    July 11, 2013
    It won't be in Windows 8.1, but hopefully soon thereafter. Thanks for your feedback. It helps us in setting priorities.

  • Anonymous
    July 11, 2013
    Thanks. Unfortunately, I'm still searching for decision or workaround to use any RichEdit >=6.0 control in my application. Ok, I'll wait and think.

  • Anonymous
    September 26, 2016
    Can't find rich edit 8 in win 10, RICHEDIT60W in win 10 failed, and can't use BuildUpMathSucceed with office 2013 RICHED20.DLL.Anyway to use BuildUpMath in win7 and higher OS without office?