You can display tables and borders with rich edit. The following will show a box with solid borders:
str = L"{\\rtf1\
\\trowd\\trgaph72 \
\\clbrdrt\\brdrdot\\clbrdrl\\brdrdot\\clbrdrb\\brdrdot\\clbrdrr\\brdrdot \
\\cellx3000 TEXT\\intbl\\cell \
\\row\\pard\\par\
}";
If you run this in Microsoft Word it will show dotted lines like it's supposed to. RichEdit does not handle dotted borders like it's supposed to, or maybe it's expecting a different format. If you save the file from Word, it still doesn't show dotted lines.
If you don't need dotted lines then use these simpler examples to show boxes in RichEdit:
CString str;
str = L"{\\rtf1\
\\trowd\\trgaph72 \
\\cellx3000 TEXT\\intbl\\cell \
\\row\\pard\\par\
}";
str = L"\
{\\rtf1\\ansi\\deff0\
\\trowd\
\\cellx1000\
\\cellx2000\
\\cellx3000\
\\ TEXT1\\cell\
\\ TEXT2\\cell\
\\ TEXT3\\cell\
\\row\
}";
See also link
Note, CRichEditCtrl::SetWindowText
will simply call ::SetWindowText
WinAPI, it will set the string as plain text.
Use CRichEdit::StreamIn
to set raw rtf string. In your case you are probably using your own class which overrides CRichEditCtrl::SetWindowText
and runs the necessary streaming.
Try the following to get rtf string from Word's spell check RichEdit:
DWORD __stdcall rtfstreamget(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
CStringA text;
text.GetBufferSetLength(cb);
CStringA *ptr = (CStringA*)dwCookie;
for(int i = 0; i < cb; i++)
text.SetAt(i, *(pbBuff + i));
*ptr += text;
*pcb = text.GetLength();
text.ReleaseBuffer();
return 0;
}
bool GetRTF(hWnd, CString &sW)
{
CStringA sA;
EDITSTREAM es{ 0 };
es.dwCookie = (DWORD_PTR)&sA;
es.pfnCallback = rtfstreamget;
edit.StreamOut((CP_UTF8 << 16) | SF_USECODEPAGE | SF_RTF, es);
SendMessage(hWnd, EM_STREAMOUT,
(CP_UTF8 << 16) | SF_USECODEPAGE | SF_RTF, (LPARAM)&es);
sW = CA2W(sA, CP_UTF8);
return es.dwError == 0;
}
CStringW s;
GetRTF(msword_spellcheck_hwindow, str);