Re: Converting text to Rich Text Format



That was a good article. Is there any was you can extend this example to solve
my problem? It might make another good article.

A member function of a class that takes three input parameters
(a) text string // std::string or CString, unicode or not
(b) LOGFONT
(c) COLORREF (text foreground color)
and produces one output which is a text string that represents the input after
it has been transformed into RTF. In the ideal case this class would have two
operators: operator=() and operator+=(), the last operator would append this new
RTF text to the prior RTF text, updating the RTF header with additional font
info only when needed. operator=() would always replace the font header info
with the font header corresponding to the new text.


"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:nbh7g2dpt9o0d1h7jj01blat7u9chja4lp@xxxxxxxxxx
See my new essay

http://www.flounder.com/riched20bug.htm

What is amazing is that there is no KB article describing this bug or the
workaround!
joe
On Sat, 09 Sep 2006 18:59:21 -0400, Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
wrote:

OK, the details are

Version 5.30.12.1211 8/29/2002 6:40am shows the error based on a
misinterpretation of CRLF
sequences
Version 5.30.12.1221 8/4/2004 3:56am does not have the error

The timestamps are those reported by the "Show Modules" debug WIndow in VS.NET
2003.

So it apparently matters which version of DLL you are using. I'm going to
have to put a
test in to make sure that I do the right compensation. I have to check to see
if Riched20
is redistributable. My recollection was that it wasn't.
joe
On Sat, 09 Sep 2006 15:52:20 -0400, Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
wrote:

What is really strange is that on my laptop I *don't* get the creep. I was
just out
somewhere where my role had been to provide transportation, but I had nothing
to do. I
noticed the "inverse creep". I will compare control DLL versions and report
back when I
have my laptop up again.

I suspected that, but when I replaced \r\n with just \n, the text looks the
same (unlike
an ordinary CEdit) but the count is still wrong.
joe


On Sat, 09 Sep 2006 00:19:11 -0700, "Mihai N." <nmihai_year_2000@xxxxxxxxx>
wrote:
There is a "creep" where the SetSelection selects the wrong text depending
on how many
lines precede the text. No, I don't know what is wrong here, and there
appears to be no
documentation about the problem, but I noticed that the colors were slowly
moving to the right.

I'm not sure this will work correctly in the presence of line wrap, but
all
my output fits on one line at the moment.

Some time ago I have noticed that a "\r\n" (0d 0a) in the original string
ends up counted as one character in the RTF (probably the \par).
So:
rtfControl.AddString( "a\r\n" );
rtfControl.AddString( "b\r\n" );
rtfControl.AddString( "c\r\n" );
means a#b#c# (# = "paragraph character", whatever that is in the belly of
the
rtf control.) So trying to select the first line (length 3, in the original
text) will end up selecting a#b
And the more lines you have, the worse it gets :-)

I am not sure if this is your case, but I though it is worth mentioning.
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm


.



Relevant Pages

  • Re: Converting text to Rich Text Format
    ... Similarly, with a LOGFONT, note that BYTE bCharSet, BYTE bPitchAndFamily; ... RTF text to the prior RTF text, updating the RTF header with additional font ... MVP Tips: http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)
  • Re: convert file from
    ... Word MVP FAQ site: http://word.mvps.org ... please post all follow-ups to the newsgroup so ... > They ARE saved as Word doc, but still want to open as RTF, and the columns ... >> is something in the file that Word is interpreting as RTF format. ...
    (microsoft.public.word.docmanagement)
  • Re: Microsoft Works Translation on Macintosh
    ... I tell my students to use Save As RTF in MS Works, ... Microsoft Works Word Processing files to Word Documents on the ... A secondary option would be to correctly convert the .wps files ... Daiya Mitchell, MVP Mac/Word ...
    (microsoft.public.mac.office.word)
  • Re: XML to RTF parsing
    ... You might consider using XSLT to generate RTF. ... Miha Markic [MVP C#] ... Blog: http://cs.rthand.com/blogs/blog_with_righthand/ ... > There is an XML file, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: sending report as an attachment
    ... >> Thanks a lot Alex. ... >> involment, just clicking a button. ... For RTF it's no ... >Regards - Joe ...
    (microsoft.public.access.modulesdaovba)