Using TRichView (Demo) for the first time ...

General TRichView support forum. Please post your questions here
Post Reply
nmadani
Posts: 2
Joined: Sun Oct 22, 2017 1:21 pm

Using TRichView (Demo) for the first time ...

Post by nmadani »

I just downloaded and installed the TRichView demo:
On a simple form (Delphi Tokyo 10.2.1), should not the following display the contents of a file?

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  ss: TStringStream;
const
  CR: Byte = 13;
  LF: Byte = 10;
begin
  ss := TStringStream.Create;
  try
    ss.LoadFromFile('c:\Temp\Document.rtf');
    Memo1.Lines.Text := ss.DataString;
//    RichViewEdit1.LoadRTF('c:\Temp\Document.rtf'); // Does not show text
    ss.Position := 0;
//    RichViewEdit1.UseStyleTemplates := False;
    RichViewEdit1.LoadRTFFromStream(ss); // Does not show text
//    RichView1.LoadRTFFromStream(ss); // does not work either
  finally
    ss.Free;
  end;
end;
Thanks,

Navid
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Using TRichView (Demo) for the first time ...

Post by Sergey Tkachenko »

1 LoadRTF and LoadRTFFromStream are fast viewer-style methods (see http://www.trichview.com/help/viewer_vs_editor.html), it does not prepare document for displaying. You need to call Format method to display the document.
2 LoadRTF and LoadRTFFromStream add content to the end of existing document. So call Clear before.

So

Code: Select all

RichViewEdit1.Clear;
RichViewEdit1.LoadRTF('c:\Temp\Document.rtf'); 
RichViewEdit1.Format;
or

Code: Select all

ss.Position := 0;
RichViewEdit1.LoadRTFFromStream(ss);
RichViewEdit1.Format;
nmadani
Posts: 2
Joined: Sun Oct 22, 2017 1:21 pm

Re: Using TRichView (Demo) for the first time ...

Post by nmadani »

Thanks for the quick reply. I also needed to add a TRVStyle object to make it work.

I may have discovered a display bug too. I will submit it separately.
Post Reply