Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delphi RTF append

Status
Not open for further replies.

adrive

Programmer
Oct 14, 2007
12
0
0
MY
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?
 
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;
 
Why use a memory stream?

Code:
function TForm2.GetRTF(RE: TRichedit): string;
begin
  result := RE.Lines.Text;
end;
 
using .Text attribute will not carry formatting over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top