How to get RTF text into variable?

General TRichView support forum. Please post your questions here
Post Reply
Bolo
Posts: 4
Joined: Thu Feb 18, 2010 7:56 am

How to get RTF text into variable?

Post by Bolo »

How to get RTF text from RichViewEdit?
I need get formated text into String (WideString?) and put into another component. Unfortunatly - I can't use Stream :( (only variable).
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Code: Select all

// TRVAnsiString is defined as String for Delphi 3-2007, and as AnsiString for Delphi 2009+

function GetRTFString(rv: TCustomRichView): TRVAnsiString;
var Stream: TMemoryStream;
begin
  Stream := TMemoryStream.Create;
  try
    rv.SaveRTFToStream(Stream, False);
    SetLength(Result, Stream.Size);
    Stream.Position := 0;
    Stream.ReadBuffer(PRVAnsiChar(Result)^, Length(Result));
  finally
    Stream.Free;
  end;
end;
Bolo
Posts: 4
Joined: Thu Feb 18, 2010 7:56 am

Post by Bolo »

Ok, and what is "PRVAnsiChar" - Delphi7 dosent known it!
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

PRVAnsiChar and TRVAnsiString are defined in RVTypes.pas
Bolo
Posts: 4
Joined: Thu Feb 18, 2010 7:56 am

Post by Bolo »

Thanx :)
Post Reply