Combining Rich Edits

Hello,

I need to feed a large richedit with the information of other invisible RichEdits controls, so I need to copy formatted text from and to RichEdit controls.

The property RichEdit.Lines can not be used since it only handles plain text, a Stream also can not be used since LoadFromStream() operation replaces the previous RichEdit text.

The perfect way to solve this issue could be the use of the clipboard. Something like this:

Rich3.RichEdit.SelectAll;
Rich3.RichEdit.CopyToClipboard;
Rich6.RichEdit.PasteFromClipboard;

But unfortunately Fast Report does not handle the methods SelectAll, CopyToClipboard and PasteFromClipboard wich exist in Delphi RichEdit control.

Any thoughts.

TIA

Ignacio Ortiz

Comments

  • edited 7:44PM
    Try this:

    1. Create a stream
    2. Save to the stream contents of RichEdit1
    3. Save (add) to this stream contens of other unvisible RichEdits
    4. Load from this stream into your RichEdit1

    Mick
  • edited 7:44PM
    Mick.pl wrote: »
    Try this:

    1. Create a stream
    2. Save to the stream contents of RichEdit1
    3. Save (add) to this stream contens of other unvisible RichEdits
    4. Load from this stream into your RichEdit1

    Mick

    Hi Mick,

    Thank you for your suggestion. But I'm afraid it does not work, the (add) to stream hides the previous RichEdit information. I believe is because that each add on the stream stores the complete richedit document information (start, fonts, end, etc.) and this indeed resets the richedit control.

    Regards,
  • gpigpi
    edited 7:44PM
    Try to fill result TRichEdit with your code from your first post and then copy result TRichEdit with TMemoryStream
  • edited 7:44PM
    If you don't need to concatenate two or more RichEdits then try to use:

    Rich2.Assign( Rich1)

    and then set bounds of Rich2 properly.

    Mick
  • Anu de DeusAnu de Deus Hampshire, UK
    edited 7:44PM
    I'm don't have any idea on how a RichText is stored, but isn't it based on some kind of text tags, like HTML or XML?
    If it is, just find the contents between the 'start' and 'end' tags, concatenate them together and put in one final richtext.
    (that's what I used to do when I first wanted to merge 2 or more fastreports files)
  • edited 7:44PM
    Ignacio,

    You can save your RichEdit text to a file (or use Wordpad to save something in rtf file) and then open it with eg. Notepad to see the structure of that kind of file. You may see only bushes over there. I tried to concatenate two long binary fields in my database which hold rtf files. But it gave no succes [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> In my opinion you should: 1a. Search the Net for[/img] technical documentation of rtf files format as Anu de Deus suggests
    1b. Ask Google about -> concatenate rtf files (I found lots of links a while ago)

    2. If you find something fine, then write your own function that will merge RichEdits using files or variables
    3. LoadFromFile(Stream) such a merged file.

    Yes I know using files inside a report to manage components seems very strange, but it could be interesting if you do not have any other choice [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Please let us know about results of your tests - like the above or any other you've already made or will make yourself. Mick[/img]
  • edited 7:44PM
    And one more quick idea.
    Do your RichEdit texts can be put on a page one above another?
    If so then you can manipulate TfrxRichEdit components laying them on a streched band in order that you need.

    Mick

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.