Hello
I would like to know if there is some variable that can receive a formatted text.
If yes, can you post some example of how can I use it?
Thanks.
Format a variable
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 20
- Joined: Fri Jun 03, 2011 8:33 pm
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Delphi string can contain arbitrary binary data, so you can store data in RVF format in a string.
The code below uses TRVAnsiString type (String for Delphi 4-2007, AnsiString for Delphi 2009-XE)
The code below uses TRVAnsiString type (String for Delphi 4-2007, AnsiString for Delphi 2009-XE)
Code: Select all
uses RVTypes;
function SaveToSting(rv: TCustomRichView): TRVAnsiString;
var Stream: TMemoryStream;
begin
Stream := TMemoryStream.Create;
rv.SaveRVFToStream(Stream, False);
SetLength(Result, Stream.Size);
Stream.Position := 0;
Stream.ReadBuffer(PRVAnsiChar(Result)^, Length(Result));
Stream.Free;
end;
Code: Select all
procedure LoadFromString(rv: TCustomRichView; const s: TRVAnsiString);
var Stream: TMemoryStream;
begin
Stream := TMemoryStream.Create;
Stream.WriteBuffer(PRVAnsiChar(s)^, Length(s));
Stream.Position := 0;
rv.LoadRVFFromStream(Stream);
Stream.Free;
rv.Format;
end;