General > The Workshop

Making RichEdit work properly on Windows 10

(1/11) > >>

jj2007:
After "upgrading" one of my machine to Windows 10, I discovered a glitch in its handling of the RichEdit control:
When launching RichMasm the first time, a message box pops up saying "msptls.dll missing".

On further investigation, it turns out that this DLL sits in C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE12\MSPTLS.DLL, together with the RICHED20.DLL that RichMasm loads successfully.

This is fixed for RichMasm in the latest MasmBasic release, and MB coders can test the workaround (attached) with e.g.

include \masm32\MasmBasic\Res\MbGui.asm
  GuiControl MyRich, "richedit"
  SetWin$ hMyRich=FileRead$(CL$())
GuiEnd

Chances are that you will never encounter the "msptls.dll missing" box, because most of the time people simply use

--- Code: ---invoke LoadLibrary, chr$("RichEd20.dll") or
invoke LoadLibrary, chr$("msftedit.dll")
--- End code ---

Both load the DLL from C:\Windows\System32. While I have not tested the msftedit dll extensively (it looked crappy), I did work a lot with RichEd20. It is buggy, too, but we know our workarounds. What is remarkable, though, is that the System32 version is SLOOOOOW. You won't notice any problems with e.g. \Masm32\Examples\*.asm, but beyond a few hundred lines, loading a file into a richedit control becomes a PITA.

The solution is to use a better version. Only Murray Sargent ("I'm a software development engineer in Microsoft Office and have been working mostly on the RichEdit editor since 1994.") knows why M$ offers the crappy DLL in System32, but fortunately, there is a solution: Use the Office version, e.g.:

--- Code: ---C:\Program Files (x86)\Common Files\microsoft shared\Office11\RICHED20.DLL
C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\RICHED20.DLL
--- End code ---

RichMasm does this automatically for you, and MB coders can use

--- Code: ---  MbLoadRich PROTO
  call MbLoadRich
--- End code ---

Put an int 3 in front if you want to discover the magic workaround that makes the Office12 version work on Win10 ;-)

Depending on availability, you get Office11, then Office12, then Sys32.
The fastest one is Office11, O12 is 10% slower, Sys32 is a factor 25 or so slower.

OK, you checked, and that folder doesn't exist :(
On my Win8.1 PC that I "upgraded" to Win10, both folders are present but only Office12 has the DLL in it. That is why I got the error box. No idea whether Office12 is installed by default, and why.

Anyway, M$ is at your service: View, print and copy Word documents, even if you don't have Word installed. This download is a replacement for Word Viewer 2003
Install it (24 MB), then discover a new folder and a fast RichEdit control.

EDIT: Attached Mini_Rtf_Reader.exe needs a filename in the commandline, otherwise it throws an exception.

hutch--:
I think you get the speed loss from using RTF rather than plain text. I still use the DLL call to rich edit 2 and because of the plain text only it will load many megabytes quickly.

jj2007:

--- Quote from: hutch-- on May 25, 2016, 07:46:50 PM ---I think you get the speed loss from using RTF rather than plain text. I still use the DLL call to rich edit 2 and because of the plain text only it will load many megabytes quickly.
--- End quote ---

Hutch,
What you write is correct, but why use a rich edit control for poor text? It is meant for rich text, and there is no excuse that my bigger files load a factor 50 slower with the crappy System32 OS version. Or that msftedit.dll has fat bugs:

If only I could convince the RichEdit50W EM_STREAMOUT message that occasionally "forgetting" a line feed is not an acceptable behaviour

Even the man behind RichEdit complains:


--- Quote ---MurrayS
March 26, 2009 at 12:42 pm   

RichEdit is developed by Microsoft Office and is a basic component in this program suite. Two versions (RichEdit 3.0 and 4.1) are also distributed with Windows. They shipped originally with Office 2000 and Office 2002. We’ve been hoping to ship a newer version in Windows for some time, but testing the huge backward compatibility scenarios and writing the up-to-date documentation have been stumbling blocks. Comments like yours help increase the priority. Thanks
--- End quote ---

We are now 2016, 22 years after Murray Sargent started working on it. The latest finest Windows 10 RichEd.DLL is still slow as hell: 20 seconds to load my 1.5MB testbed, instead of 0.8 seconds with the Office version. With the Office11 RichEd20.dll, you can load 80MB of rich text in about 5 seconds. This is ok, but why does the crappy OS version still hang around? To discourage developers from using RichEdit?

This is Microsoft at its best :redface:

P.S.: So far I found 4 versions of RichEd20.dll - note the deliciously consistent versioning system:

--- Code: ---C:\Windows\System32\riched20.dll:
Rich Text Edit control v 3.1
5.31.23.1230
NAME: Microsoft Rich Text Edit control version 3.1
473600 bytes, 21 Nov 2010

Office11 folder:
Version 5.0
5.50.99.2050
NAME: Copyright Microsoft 1997-2006
original file name MsftEdit.dll
1103280 bytes, 18 June 2007

Office12 folder:
Version 6.0
12.0.6500.5000
NAME: 2007 Microsoft Office system
1017176 bytes, 26 Feb 2009

Office 2010 (?):
Version 6.0
14.0.4750.1000
NAME: Microsoft Office 2010
1366376 bytes, 1 Oct 2010
--- End code ---

TWell:
My small test with small RTF-file 48 Mb.

--- Code: ---riched20.dll:  8727 ms v 3.1
riched20.dll:  1254 ms v 4.0
riched20.dll:  1421 ms v 5.0
msftedit.dll:  2163 ms v 4.1
msftedit.dll:  1911 ms v 7.5 Windows 8.1
msftedit.dll: 12027 ms v 7.5 Windows 10

--- End code ---

jj2007:
Doesn't look very plausible. How did you fill the control? Can you post the test?

EDIT: Tim sent me a fat RTF, and I did some tests:

--- Code: ---Timings (seconds)
1.1 Office 2010 RichEd20.DLL *)
1.5   Office 2010, version 4 <<< compact and fast, correct as 6.0, added by Tim 26.5.
1.8 Office11 folder
2.2 Office12 folder
15.0 Windows\System32\RichEd20.dll
--- End code ---

So we have a clear winner: Tim's Office 2010 version. But check the screenshot below - it loads only 50% of the doc... ::)

Note that the math formulas appear correctly in MS Word and WordPad - they are saved as images, apparently. The doc is 48MB, but saved as plain text, only 0.7MB remain, so there must be plenty of embedded images.

Given that the official Sys32 (last screenshot) is just slow and crappy, the choice is basically between the versions that the free Word viewers install as C:\Program Files (x86)\Common Files\microsoft shared\Office1?\RICHED20.DLL (see Oct 2013 thread)

The Office11 folder gets filled by the free Word Viewer (recommended, the best and fastest RichEd20 imho), the Office12 folder by the free Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint File Formats.

Navigation

[0] Message Index

[#] Next page

Go to full version