Re: Converting text to Rich Text Format
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Fri, 08 Sep 2006 12:54:14 -0400
Add the string. Set its style.
There is one little glitch in setting the selection which I discovered last night (since
I'm currently using a rich edit control to display some text). If you do
int length = c_Text.GetLength();
c_Text.SetSel(length, length);
int line = c_Text.LineFromChar(length); // see discussion below
c_Text.ReplaceSel(length);
CHARFORMAT2 fmt;
fmt.dwMask = CFE_COLOR;
fmt.crTextColor = ...;
int end = c_Text.GetLength();
c_Text.SetSel(length - line, end - line);
c_Text.SetSelectionCharFormat(fmt);
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.
joe
On Fri, 8 Sep 2006 09:49:23 -0500, "Peter Olcott" <NoSpam@xxxxxxxxxxxxx> wrote:
Could you describe the process of converting text to Rich Text using the RichJoseph M. Newcomer [MVP]
Edit Control, given an array of strings each with corresponding LOGFONT and
(foreground color)COLORREFs?
These are the only formatting aspects that I need to retain, I do not need any
paragraph formatting attributes such as left/right/center justification.
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:t8v2g21h8845bkf2jnknqkrtdiemaolgk6@xxxxxxxxxx
CRichEdit::SetSel
joe
On Thu, 7 Sep 2006 23:24:58 -0500, "Peter Olcott" <NoSpam@xxxxxxxxxxxxx>
wrote:
I could drop the text into a Rich Edit Control, and then the user couldJoseph M. Newcomer [MVP]
cut-and-paste it to anywhere they want. What I don't get about this is how you
make a text selection in a Rich Edit Control, programmatically.
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:idq1g21fgr4lmotft494h6qsfihte7qfpd@xxxxxxxxxx
You can use SetSelectionCharFormat in the rich edit control, or use the
StreamIn to read
encoded RTF. It's up to you which makes sense in your application. Note
the
rtf doesn't
have to be in a file, because StreamIn doesn't care how you deliver the
text.
joe
On Thu, 7 Sep 2006 15:38:23 -0500, "Peter Olcott" <NoSpam@xxxxxxxxxxxxx>
wrote:
I was hoping that there was a short-cut to this method by using the RichJoseph M. Newcomer [MVP]
Edit
Control.
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:v5u0g2d40nq4tam0tsl8vpv04agmpkh7km@xxxxxxxxxx
You have to read about the Rich Text Format syntax. Or a simple way,
format
the text you
want in WordPad and write it out, then look at what got written and
replicate
it.
joe
On Thu, 7 Sep 2006 13:30:32 -0500, "Peter Olcott" <NoSpam@xxxxxxxxxxxxx>
wrote:
If I start with a set of text strings where each text string is associatedJoseph M. Newcomer [MVP]
with
a LOGFONT and COLORREF (for its foreground color), how do I convert this
to
Rich
Text Format?
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: Converting text to Rich Text Format
- From: Mihai N.
- Re: Converting text to Rich Text Format
- From: Michael K. O'Neill
- Re: Converting text to Rich Text Format
- From: Peter Olcott
- Re: Converting text to Rich Text Format
- References:
- Converting text to Rich Text Format
- From: Peter Olcott
- Re: Converting text to Rich Text Format
- From: Joseph M . Newcomer
- Re: Converting text to Rich Text Format
- From: Peter Olcott
- Re: Converting text to Rich Text Format
- From: Joseph M . Newcomer
- Re: Converting text to Rich Text Format
- From: Peter Olcott
- Re: Converting text to Rich Text Format
- From: Joseph M . Newcomer
- Re: Converting text to Rich Text Format
- From: Peter Olcott
- Converting text to Rich Text Format
- Prev by Date: Re: Installation files
- Next by Date: Re: Communicating between worker threads..
- Previous by thread: Re: Converting text to Rich Text Format
- Next by thread: Re: Converting text to Rich Text Format
- Index(es):
Relevant Pages
|