mfc >> Insert RTF to CRichEditCtrl

by SG9uZw » Fri, 24 Mar 2006 16:22:05 GMT

I want to get rtf from a CRichEditCtrl, then insert into another CRichEditCtrl.
but the problem is: it always create new line after I call streamin.
I refernece WordPad and Microsoft Word.if I copy whole line,the paste to
another document, it will create new line. if only copy part of one line, it
will get single line.
then, I made two line, firs is left align, sencond is center align,
if I select all and copy, when paste into another document, it will create
new line.
if I select all first line and part of sencond line. it shows all left align.

what I like is get whole format of rtf(text font,color,size,bold,paragh
format), and insert into another RTF text, do not creat new line, keep all
format.
How could I do.
what I found is:
original: {{\rtf1\......\pard\fs24 "original text"\par}
after insert {{\rtf1\.....\pard\fs24 "insert text"\par \pard "original
text"\par}
I'd like such as {{\rtf1\...\pard\fs24 "insert text + orginal text"\par}
sometime there is no the second "\pard".


Similar Threads

1. Pixel length of a RTF string BEFORE it is inserted into a CRichEditCtrl

2. Problem displaying RTF in CRichEditCtrl

I have an app that uses CRichEditCtrl in various places to display RTF text. 
Typically, I have the RTF stored as a string resource, and I just load it and 
call SetWindowText() to display it.

That all worked perfectly well for quite some time. Recently, I updated to 
VS2008 and VC9, and now I've noticed that this seems to have broken. 
Specifically, if I pass a wide-character string containing RTF text 
specifications (e.g., "{\rtf\...}"), the control displays the actual RTF 
syntax as plaintext without interpreting it. If, however, I pass the string 
as single-byte text, it displays as rich text, with formatting and all.

I compile with _UNICODE set, I've specified RichEdit20W in the dialog 
templates, I pass a CString to SetWindowText(). I look in the disassembly and 
it appears that SetWindowTextW() is getting called. Sending a WM_SETTEXT 
message instead of SetWindowText() makes no difference. Before setting the 
text, I call SetTextMode() on the control with (TM_RICHTEXT | 
TM_MULTICODEPAGE).

As I said, all of this worked before, but something has changed. Any ideas 
what it might be?

3. plain RTF inside CRichEditCtrl

4. Printing RTF text using a hidden CRichEditCtrl

5. CRichEditCtrl::Create and RTF format

6. CRichEditCtrl RTF Version.

Hi All -

Does the CRichEditCtrl MFC object in later versions (I'm on 6)
implement a later version of Rich Text (CRichEditCtrl implements
version 1.0 in vc6)?

Thanks,

7. CRichEditCtrl contents from RTF file

8. Shading and borders with CRichEditCtrl (RTF 1.x)

I'm using a RichEditCtrl (RTF 1.0) in a C++ application (VC6). I can
generate the appropriate RTF 'tags' for italic, bold, font-size,
color, superscript, etc., but I'm baffled how to generate 'tags' for
shading and borders.

I tried using Word-2003 to accomplish this formatting, save as RTF,
and open with WordPad, but the resulting file is quite large and I'm
confused trying to figure out what it is doing.

Using the rtf codes below, I want Line 6 to have a border, and Line 7
to be shaded. My expectation is that this file would load into
WordPad-XP with this formatting, but that isn't happening. Do I need
to use RichEdit20?

{\rtf1\ansi\ansicpg1252\deff0\deflang1033\deflangfe1033{\fonttbl{\f0\f
swiss\fprq2\fcharset0 Arial;}}
{\*\generator Msftedit
5.41.15.1507;}\viewkind4\uc1\pard\nowidctlpar\f0\fs20 Line 1\par
Line 2\par
\super 12 \nosupersub Line 3\par
\up8 34\up0  Line 4\par
\b Bold Line 5\par
\brdrb \brdrw40 \i Italic Bold Line 6 with border\b0\par
\shading20 \cfpat1 \cbpat1 Italic only Line 7 with shading\par
\i0\par
Line 9\par
Line 10\par
Line 11\par
}