Board index » cppbuilder » Using TRichEdit contents in another TRichEdit control

Using TRichEdit contents in another TRichEdit control

I have a TRichEdit control which has text with some words
highlighted in a different color.  I would like to use that text
(without copying it) in another TRichEdit control keeping the
same formatting (including highlighting of the words).  I set the
2 TRichEdit controls to have PlainText false and WordWrap true.
I did the following assignment:  RichEdit1->Text =
Form1->RichEdit2->Text.  The text was copied correctly and the
word wrap conformed to the boundaries of the RichEdit1 control.
However, all of the text highlighting were gone.  Is there any
way to also keep the text formatting?
 

Re:Using TRichEdit contents in another TRichEdit control


Quote
Richard Casten <richard.cas...@aero.org> wrote in message

news:3B1E980F.1BA3E8C0@aero.org...

Quote
> I have a TRichEdit control which has text with some words
> highlighted in a different color.  I would like to use that text
> (without copying it)

I think you mean without using the Clipboard?

in another TRichEdit control keeping the

Quote
> same formatting (including highlighting of the words).  I set the
> 2 TRichEdit controls to have PlainText false and WordWrap true.

I haven't done this myself, but you should be able to create a
(temporary) TMemoryStream, myREdit->Lines->SaveToStream the first
TRichEdit, and then LoadFromStream the second TRichEdit.  I don't
think you even have to reset any position in the Stream.

--
Timothy H. Buchman
========================================
City Center Theater New York NY
tbuchmanPLEASE(at sign)REMOVEcitycenter.org
Please treat this signature information as confidential.
========================================
Search .borland newsgroup archives at:
http://www.mers.com/searchsite.html

Re:Using TRichEdit contents in another TRichEdit control


I'm trying to avoid using more memory for the 2nd TRichEdit control.  I
was hoping to simply point to the memory used by the text in the first
TRichEdit control or something like that.
Quote
"Timothy H. Buchman" wrote:
> Richard Casten <richard.cas...@aero.org> wrote in message
> news:3B1E980F.1BA3E8C0@aero.org...
> > I have a TRichEdit control which has text with some words
> > highlighted in a different color.  I would like to use that text
> > (without copying it)

> I think you mean without using the Clipboard?

> in another TRichEdit control keeping the
> > same formatting (including highlighting of the words).  I set the
> > 2 TRichEdit controls to have PlainText false and WordWrap true.

> I haven't done this myself, but you should be able to create a
> (temporary) TMemoryStream, myREdit->Lines->SaveToStream the first
> TRichEdit, and then LoadFromStream the second TRichEdit.  I don't
> think you even have to reset any position in the Stream.

Re:Using TRichEdit contents in another TRichEdit control


Quote
Richard Casten <richard.cas...@aero.org> wrote in message

news:3B1EC1FF.B69C4ED5@aero.org...

Quote
> I'm trying to avoid using more memory for the 2nd TRichEdit control.
I
> was hoping to simply point to the memory used by the text in the
first
> TRichEdit control or something like that.

That's an *addition* to the specifications!  Certainly the ->Text
assignment code you posted won't do that.  I don't have an immediate
suggestion.  Are both RichEdits visible at the same time?  What is the
difference between the two displays?

--
Timothy H. Buchman
========================================
City Center Theater New York NY
tbuchmanPLEASE(at sign)REMOVEcitycenter.org
Please treat this signature information as confidential.
========================================
Search .borland newsgroup archives at:
http://www.mers.com/searchsite.html

Re:Using TRichEdit contents in another TRichEdit control


Both RichEdits are not visible at the same time.  I simply want to use the
contents (text and its attributes, and no other properties) of one
RichEdit  in another RichEdit without having to load the second one.
Quote
"Timothy H. Buchman" wrote:
> That's an *addition* to the specifications!  Certainly the ->Text
> assignment code you posted won't do that.  I don't have an immediate
> suggestion.  Are both RichEdits visible at the same time?  What is the
> difference between the two displays?

Re:Using TRichEdit contents in another TRichEdit control


Quote
Richard Casten <richard.casten> wrote in message

news:3B1F9F47.D8BC5B75@aero.org...

Quote
> Both RichEdits are not visible at the same time.  I simply want to
use the
> contents (text and its attributes, and no other properties) of one
> RichEdit  in another RichEdit without having to load the second one.

I take it there is a vast amount of text, since you said you want to
save memory.  But the fact is that a RichEdit isn't just a display
device, it stores the text and attributes itself, and has methods that
act on them.  I can only suggest some ideas:
1) Find a 3rd party component that displays remotely held text
2) Move the *same* RichEdit from one Parent to another for the second
display
3) Derive a sort of virtual RichEdit that only contains the text
that's visible at the time.
4) Find out how Word and Excel conserve resources.

I've read some comments about 4) in this newsgroup, but I know *no*
details.  Apparently, even though they have vast numbers of Controls
and MDI interfaces, they use relatively few Windows resources and
Handles by displaying things that look like Controls that aren't,
until you click on them.  I suspect it's a secret of Redmond.

I'm a little nervous about "and no other properties".  If the user
can't scroll the second RichEdit, perhaps you could copy the DC of the
real RichEdit and display the rendered canvas statically in the second
form.

I presume you've read Robert Dunn's work,
http://home.att.net/~robertdunn/Yacs.html  Almost everyone finds
RichEdit to have many irritations.  You could spend a lot of time
tampering with the component.  I wonder if (after making sure that the
memory is really "released" and reusable when the Lines are Clear-ed)
you might consider my original idea, but only have one of the
RichEdit's actually Load-ed at a time.  That's all I can offer.
-------
Timothy H. Buchman
========================================
City Center Theater, New York NY
mail address tbuchmanPLEASE(at sign)REMOVEcitycenter.org
Please treat this signature information as confidential.
========================================
Search .borland message archive on http://www.mers.com/searchsite.html

Re:Using TRichEdit contents in another TRichEdit control


Thanks Timothy.  Your advice has been very helpful.

Re:Using TRichEdit contents in another TRichEdit control


try taking a look at the component TaeRichEdit
search www.google.com for it and download it.
it's proven VERY useful to me when using rich edit controls.
not sure if it will help you in this case, but i'm sure it will help you
along the lines
hope this helps
slavin

Quote
"Richard Casten" <richard.cas...@aero.org> wrote in message

news:3B1FC2DB.72E7077D@aero.org...
Quote
> Thanks Timothy.  Your advice has been very helpful.

Other Threads