0

Hi,

Is it possible to append a trichedit component's stream to another trichedit? LoadFromStream doesn't seem to work though, perhaps theres another way to append its Tmemorystream before passing into the LoadFromStream method?

2
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by adrive
0

This is what i've been doing, but It doesn't work because RichEdit2 has its own RTF header when copied over, and RichEdit2 will not see its appended text.

procedure TForm2.Button1Click(Sender: TObject);
var
ms: TMemoryStream;
ms2: TMemoryStream;
begin

Memo1.Text := GetRTF(RichEdit1);
Memo1.Text := Memo1.Text + GetRTF(RichEdit2);

RichEdit2.Text := Memo1.Text;
end;

function TForm2.GetRTF(RE: TRichedit): string;
var
strStream: TStringStream;
begin
strStream := TStringStream.Create('') ;
try
RE.PlainText := False;
RE.Lines.SaveToStream(strStream) ;
Result := strStream.DataString;
finally
strStream.Free
end;
end;

0

That was my first thought too, but I realized that very problem would occur. Having thought it over some the answer is embarrassingly obvious: just cut and paste the text.

Hope this helps.

0

str := Clipboard.AsText;
Clipboard.AsText := '';
RichEdit1.SelectAll;
RichEdit1.CopyToClipboard;
RichEdit2.PasteFromClipboard;

Clipboard.AsText := str;

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.