News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Msftedit.dll

Started by Mikl__, May 29, 2019, 09:17:30 PM

Previous topic - Next topic

jj2007

Quote from: AW on May 31, 2019, 01:09:00 AMTables are a mess to work with.

I have no urgent need for tables, but they do work in the Office11 and Office12 controls.

QuoteMath symbols don't work, despite claims.

There are certainly some big problems with math symbols, see the red text.


aw27

Quote
There are certainly some big problems with math symbols, see the red text.

sic from Murray " the Microsoft Equation Editor 3.0 (MEE) was removed from Office installations because it has security problems and no maintenance. " . And there is the buggy latex way. And there is something new in RichEdit 9, but it sounds like nobody has ever seen it. I have Office 2019. Is it from Office 365?

Nope, Murray says: " we might as well call the current one RichEdit 9, This covers RichEdit up through Office 2019 and includes some features of more recent Office 365 versions."
But Office 2019 has RichEdit version 8, not 9.  :joking: :joking: :joking:
Is Murray, well of his mind?


TimoVJL

One riched20.dll (16.0.4639) even try to show picture :thumbsup:
Almost there :biggrin: , but it didn't show file content  :sad:

What kind of programmers are in richedit team :undecided:
Different results between versions, crashing, ...
Not so professional way for programming. Have they heard about SEH, how to use it :undecided:
Murray can have some problems with that team.
May the source be with you

aw27

#18
To the left from Office 2016 to the right from Office 2019. (both updated today).



The one from Office 2019 is 550KB smaller.   :rofl: :rofl: :rofl:

Later: I forgot that the one on the left is 64-bit, the one on the right is 32-bit. So the difference in size is explained. Very likely, they have the exact same features.

TimoVJL

So now we know some details of version 8, it have a some native support for pictures :thumbsup:
For example version 16.0.8907

May the source be with you

jj2007

Hi Timo, have you seen the RtfSpecs?

TimoVJL

Thanks :biggrin:
Nice :thumbsup:
Now we can test how riched20.dll works with it depending versions.
Also those speed test are now possible with common material.
May the source be with you

aw27

I attach a fairly comprehensive RTF file. It is correctly displayed in Word and with a demo built with the TRichView component, I have mentioned earlier, like this:



Can anyone do the same with the RichEdit control in less than one week? Just a challenge...

jj2007

Quote from: AW on June 01, 2019, 02:26:00 AMCan anyone do the same with the RichEdit control in less than one week? Just a challenge...

Difficult  :biggrin:

Much of this stuff works fine in RichMasm, but OLE is not implemented, i.e. no embedded images, and hyperlinks work fine but they use the bb code syntax, i.e. url= ... text /url etc.

Tables work fine, math symbols work (http://masm32.com/board/index.php?topic=7885.msg86465#msg86465) with at least the Office14 version - and you must be very, very careful, the control is buggy, and several math symbols cause bad crashes. RM has two recover mechanisms, but still, I wouldn't recommend the math stuff.

TimoVJL

riched20.dll 16.0.8907.1000 was able to read Word2007RTFSpec_1.9.rtf and show pictures without additional OLE code  :eusa_clap:
And that x64 version don't even need msptls.dll, it only mess things. So versions don't even behave similar way, what a mess.

But it don't handle Jose's rtftest.rtf

So riched20 from version 8 starts finally doing those things, but it took quite a long time by those "professional" MS programmers :skrewy:

Those who have those newer versions could test reading that Word2007RTFSpec_1.9.rtf and read what abandoned specs says.

A sad story :undecided:
May the source be with you

aw27

I think you will need to implement the IRichEditOleCallback interface, but I never tried.  :sad:

TimoVJL

#26
Basic IRichEditOleCallback works only with OS riched20.dll and mstfedit.dll, but with not those Office riched20.dll versions  :sad:

EDIT: ITextDocument2  was a problem for opening a file.
Minimal code example in ASM
.model flat,stdcall
includelib "ole32.lib"

CoMethod1Proto typedef proto :DWORD
CoMethod2Proto typedef proto :DWORD, :DWORD
CoMethod3Proto typedef proto :DWORD, :DWORD, :DWORD
CoMethod4Proto typedef proto :DWORD, :DWORD, :DWORD, :DWORD
CoMethod5Proto typedef proto :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
CoMethod6Proto typedef proto :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD

CoMethod1 typedef ptr CoMethod1Proto
CoMethod2 typedef ptr CoMethod2Proto
CoMethod3 typedef ptr CoMethod3Proto
CoMethod4 typedef ptr CoMethod4Proto
CoMethod5 typedef ptr CoMethod5Proto
CoMethod6 typedef ptr CoMethod6Proto

IRichEditOleCallback STRUCT
QueryInterface CoMethod3 ?
AddRef CoMethod1 ?
Release CoMethod1 ?
GetNewStorage CoMethod2 ?
GetInPlaceContext CoMethod4 ?
ShowContainerUI CoMethod2 ?
QueryInsertObject CoMethod4 ?
DeleteObject CoMethod2 ?
QueryAcceptData CoMethod6 ?
ContextSensitiveHelp CoMethod3 ?
GetClipboardData CoMethod4 ?
GetDragDropEffect CoMethod4 ?
GetContextMenu CoMethod5 ?
IRichEditOleCallback ENDS

SendMessageA PROTO :DWORD,:DWORD,:DWORD,:DWORD
SendMessage EQU SendMessageA

CreateILockBytesOnHGlobal PROTO :DWORD,:DWORD,:PTR
StgCreateDocfileOnILockBytes PROTO :PTR,:DWORD,:DWORD,:PTR PTR

OutputDebugStringW PROTO :DWORD
OutputDebugString EQU OutputDebugStringW

public STDCALL REOCB_SetComInterface

.code
REOCB_QueryInterface PROC _This:PTR,riid:PTR,ppvObj:PTR
mov eax, 80004002h ; E_NOINTERFACE
ret
REOCB_QueryInterface ENDP

REOCB_AddRef PROC _This:PTR
mov eax, 1h
ret
REOCB_AddRef ENDP

REOCB_Release PROC _This:PTR
mov eax, 1h
ret
REOCB_Release ENDP

REOCB_GetNewStorage PROC _This:PTR,lplpstg:PTR PTR
LOCAL lpLockBytes:PTR
invoke CreateILockBytesOnHGlobal,0,1,ADDR lpLockBytes
.if eax
xor eax, eax
jmp @F
.endif
invoke StgCreateDocfileOnILockBytes,lpLockBytes,1012h,0,lplpstg
@@:
ret
REOCB_GetNewStorage ENDP

REOCB_GetInPlaceContext PROC _This:PTR,lplpFrame:PTR,lplpDoc:PTR,lpFrameInfo:PTR
mov eax, 80004002h
ret
REOCB_GetInPlaceContext ENDP

REOCB_ShowContainerUI PROC _This:PTR,fShow:DWORD
mov eax, 80004002h
ret
REOCB_ShowContainerUI ENDP

REOCB_QueryInsertObject PROC _This:PTR,lpclsid:PTR,lpstg:PTR,cp:DWORD
xor eax, eax ; S_OK
ret
REOCB_QueryInsertObject ENDP

REOCB_DeleteObject PROC _This:PTR,lpoleobj:PTR
mov eax, 80004002h
ret
REOCB_DeleteObject ENDP

REOCB_QueryAcceptData PROC _This:PTR,lpdataobj:PTR,lpcfFormat:PTR,reco:DWORD,fReally:DWORD,hMetaPict:PTR
mov eax, 80004002h
ret
REOCB_QueryAcceptData ENDP

REOCB_ContextSensitiveHelp PROC _This:PTR,fEnterMode:DWORD
mov eax, 80004002h
ret
REOCB_ContextSensitiveHelp ENDP

REOCB_GetClipboardData PROC _This:PTR,lpchrg:PTR,reco:DWORD,lplpdataobj:PTR
mov eax, 80004002h
ret
REOCB_GetClipboardData ENDP

REOCB_GetDragDropEffect PROC _This:PTR,fDrag:DWORD,frfKeyState:DWORD,pwEffect:DWORD PTR
mov eax, 80004002h
ret
REOCB_GetDragDropEffect ENDP

REOCB_GetContextMenu PROC _This:PTR,seltype:WORD,lpoleobj:PTR,lpchrg:PTR,lphmenu:PTR
mov eax, 80004002h
ret
REOCB_GetContextMenu ENDP

.data
IRichEditOleCallbackVtbl IRichEditOleCallback {REOCB_QueryInterface,REOCB_AddRef,REOCB_Release,
REOCB_GetNewStorage,REOCB_GetInPlaceContext,REOCB_ShowContainerUI,
REOCB_QueryInsertObject,REOCB_DeleteObject,REOCB_QueryAcceptData,REOCB_ContextSensitiveHelp,
REOCB_GetClipboardData,REOCB_GetDragDropEffect,REOCB_GetContextMenu}
ReOleCb DWORD OFFSET IRichEditOleCallbackVtbl

.code
REOCB_SetComInterface PROC hWnd:PTR,hEdit:PTR,pReOleCb:PTR
invoke SendMessage,hEdit,446h,0,ADDR ReOleCb
ret
REOCB_SetComInterface ENDP
END

Minimal code example in C
// ReOleCb.c for PellesC
#define WIN32_LEAN_AND_MEAN
#define WIN32_DEFAULT_LIBS
#include <windows.h>
#include <oleidl.h>
#include <richedit.h>
#include <richole.h>

#pragma intrinsic(memcpy)
//const CLSID IID_IUnknown = {0x00000000,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46};
//const CLSID IID_IRichEditOleCallback = {0x00020D03,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46};

int REFIID2String(REFIID riid, TCHAR *szREFIID)
{
return wsprintf(szREFIID,
TEXT("riid = {0x%08X,0x%04X,0x%04X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X};"),
riid->Data1, riid->Data2, riid->Data3,
riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7]);
}

STDMETHODIMP ReOleCb_QueryInterface(IRichEditOleCallback *this, REFIID riid, LPVOID *ppvObj)
{
TCHAR szTmp[100];
REFIID2String(riid, szTmp);
OutputDebugString(szTmp);

*ppvObj = NULL;
OutputDebugString(TEXT("QueryInterface"));
return E_NOINTERFACE;
}

STDMETHODIMP_(ULONG) ReOleCb_AddRef(IRichEditOleCallback *this)
{
OutputDebugString(TEXT("AddRef"));
return 1;
}

STDMETHODIMP_(ULONG) ReOleCb_Release(IRichEditOleCallback *this)
{
OutputDebugString(TEXT("Release"));
return 1;
}

STDMETHODIMP ReOleCb_GetNewStorage(IRichEditOleCallback *this, LPSTORAGE* lplpstg)
{
OutputDebugString(TEXT("GetNewStorage"));
SCODE sc;
LPLOCKBYTES lpLockBytes = NULL;

sc = CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);
if (sc != S_OK)
return 0;
sc = StgCreateDocfileOnILockBytes(lpLockBytes,
STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, lplpstg);
if (sc != S_OK) lpLockBytes->lpVtbl->Release(lpLockBytes);
return sc;
}

STDMETHODIMP ReOleCb_GetInPlaceContext(IRichEditOleCallback *this, LPOLEINPLACEFRAME *lplpFrame,
LPOLEINPLACEUIWINDOW *lplpDoc, LPOLEINPLACEFRAMEINFO lpFrameInfo)
{
OutputDebugString(TEXT("GetInPlaceContext"));
return E_NOTIMPL;
}

STDMETHODIMP ReOleCb_ShowContainerUI(IRichEditOleCallback *this, BOOL fShow)
{
OutputDebugString(TEXT("ShowContainerUI"));
return E_NOTIMPL;
}

STDMETHODIMP ReOleCb_QueryInsertObject(IRichEditOleCallback *this, LPCLSID lpclsid,
LPSTORAGE lpstg, LONG cp)
{
OutputDebugString(TEXT("QueryInsertObject"));
return S_OK;
}

STDMETHODIMP ReOleCb_DeleteObject(IRichEditOleCallback *this, LPOLEOBJECT lpoöeobj)
{
OutputDebugString(TEXT("DeleteObject"));
return E_NOTIMPL;
}

STDMETHODIMP ReOleCb_QueryAcceptData(IRichEditOleCallback *this, LPDATAOBJECT lpdataobj,
CLIPFORMAT *lpcfFormat, DWORD reco, BOOL fReally, HGLOBAL hMetaPict)
{
OutputDebugString(TEXT("QueryAcceptData"));
return E_NOTIMPL;
}

STDMETHODIMP ReOleCb_ContextSensitiveHelp(IRichEditOleCallback *this, BOOL fEnterMode)
{
OutputDebugString(TEXT("ContextSensitiveHelp"));
return E_NOTIMPL;
}

STDMETHODIMP ReOleCb_GetClipboardData(IRichEditOleCallback *this,
CHARRANGE *lpchrg, DWORD reco, LPDATAOBJECT *lplpdataobj)
{
OutputDebugString(TEXT("GetClipboardData"));
return E_NOTIMPL;
}

STDMETHODIMP ReOleCb_GetDragDropEffect(IRichEditOleCallback *this,
BOOL fDrag, DWORD frfKeyState, PDWORD pwEffect)
{
OutputDebugString(TEXT("GetDragDropEffect"));
return E_NOTIMPL;
}

STDMETHODIMP ReOleCb_GetContextMenu(IRichEditOleCallback *this,
WORD seltype, LPOLEOBJECT lpoleobj, CHARRANGE *lpchrg , HMENU *lphmenu)
{
OutputDebugString(TEXT("GetContextMenu"));
return E_NOTIMPL;
}

IRichEditOleCallbackVtbl ReOleVtbl = {
ReOleCb_QueryInterface,
ReOleCb_AddRef,
ReOleCb_Release,
ReOleCb_GetNewStorage,
ReOleCb_GetInPlaceContext,
ReOleCb_ShowContainerUI,
ReOleCb_QueryInsertObject,
ReOleCb_DeleteObject,
ReOleCb_QueryAcceptData,
ReOleCb_ContextSensitiveHelp,
ReOleCb_GetClipboardData,
ReOleCb_GetDragDropEffect,
ReOleCb_GetContextMenu,
};

IRichEditOleCallback ReOle = {&ReOleVtbl};

DWORD RichEditOleCallback_SetComInterface(HWND hWnd, HWND hEdit, IRichEditOleCallback** pReOleCb)
{
return SendMessage(hEdit, EM_SETOLECALLBACK, 0, (LPARAM)&ReOle);
}
May the source be with you

aw27

The guy seems very happy with the solution.

https://social.msdn.microsoft.com/Forums/en-US/41e834bb-b797-4c9c-9886-df79ed7e050b/how-do-i-load-an-rtf-file-containing-image-into-rich-edit-control?forum=vcgeneral

aw27

The solution from the link above works, except for icons (I can't figure out what is missing). It works also with riched20.dll from Office 2016 x64-bits.



However, the Office 2016 has problems loading some documents like the RTF specification. It interrupts the loading near the beginning.
So. there is a reason for Microsoft hiding it 7 subfolders deep (even worse for Office 2019, nearly impossible to find where its riched20.dll is).
The bottom line is: Don't use the MS Office riched20.dll until Mr. Murray starts documenting things properly instead of producing useless marketing blogs.

jj2007

Quote from: AW on June 04, 2019, 07:49:03 PMDon't use the MS Office riched20.dll until Mr. Murray starts documenting things properly instead of producing useless marketing blogs.

For many years I used the Office11 version, stable and so far the fastest one. About two years ago I switched to Office12, marginally slower but has a few features more. So far it's pretty stable (I use it several hours every day). It comes with the free Excel viewer - officially retired by M$ but available on several dedicated sites.

Later versions may offer more bells and whistles, but prepare for crashes.