Board index » delphi » Q: D2, Copying RichEdit to another RichEdit

Q: D2, Copying RichEdit to another RichEdit

Hi!
I have tried for several days to find out how to do this, but with no luck.

PROBLEM:

I have two forms with a TRichEdit on each.
When I try to copy the contents of one to the other, I only get the text,
but not the formatting.

1. How can I copy the text AND the formatting with it?
2. How can I save the RichEdit contents to a Paradox database?

Anyone know this?

-Geir Bratlie-
 ro...@sn.no

 

Re:Q: D2, Copying RichEdit to another RichEdit


On 24 Nov 1996 16:17:08 GMT, "Geir Bratlie" <ro...@sn.no> wrote:

Quote
>I have two forms with a TRichEdit on each.
>When I try to copy the contents of one to the other, I only get the text,
>but not the formatting.

>1. How can I copy the text AND the formatting with it?

Haven't tested this:

Form1.RichEdit.SelectAll;
Form2.RichEdit.SelText := Form1.RichEdit.SelText;

     Rogier Meurs  -  0meur...@lelystad.flnet.nl

        Visit the RogSoft NotePad+ HomePage!
 NotePad+ is the Free Win95 Notepad replacement that
          eats standard Notepad for lunch!
        http://lelystad.flnet.nl/~0meurs01/

Re:Q: D2, Copying RichEdit to another RichEdit


No, this only copies the text and not the formatting.

Thank you for your suggestion :)

-Geir-

Re:Q: D2, Copying RichEdit to another RichEdit


On 24 Nov 1996 16:17:08 GMT, "Geir Bratlie" <ro...@sn.no> wrote:

Quote
>I have two forms with a TRichEdit on each.
>When I try to copy the contents of one to the other, I only get the text,
>but not the formatting.

>1. How can I copy the text AND the formatting with it?
>2. How can I save the RichEdit contents to a Paradox database?

Use streams.
--
Ray Lischner, Tempest Software, Inc., Corvallis, Oregon, USA
Author of Secrets of Delphi 2 (http://www.tempest-sw.com/secrets/)

Re:Q: D2, Copying RichEdit to another RichEdit


In article <3299e320.28902...@news.flnet.nl>, 0meur...@lelystad.flnet.nl

Quote
(Rogier Meurs) wrote:
>On 24 Nov 1996 16:17:08 GMT, "Geir Bratlie" <ro...@sn.no> wrote:

>>I have two forms with a TRichEdit on each.
>>When I try to copy the contents of one to the other, I only get the text,
>>but not the formatting.

>>1. How can I copy the text AND the formatting with it?

>Haven't tested this:

>Form1.RichEdit.SelectAll;
>Form2.RichEdit.SelText := Form1.RichEdit.SelText;

Hello there,

You have come to the same problem we did in our Stickits and Mail Express
programs. We heavily transfer one rtf to another, or to disk etc. The best way
that we could think of was to create a memory stream on the fly, savetostream
and loadfrom stream.

Example:

Var
  MyStream:TStream; // I don't think you can use TMemoryStream here!
Begin
   MyStream:=TMemoryStream.Create;
   STextBox.SaveToStream(MyStream); // Saves to stream
   MyStream.Position:=0; // IMPORTANT!!!
   NewTextBox.LoadFromStream(MyStream) // Loads from stream
   MyStream.Free;
 end;

The above code is the only thing that's fast and smooth. Don't use the
clipboard because you don't want to make users angry when they loose info.

 If you ever come across a direct way to do things that bypass the TConversion
 routines please let me know ;)

-Andy Brunner
References
{*word*104}Creek http://www.{*word*104}creek.com/

Other Threads