Page 1 of 1

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

Posted: Sun Oct 22, 2017 1:29 pm
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

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

Posted: Sun Oct 22, 2017 5:22 pm
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;

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

Posted: Sun Oct 22, 2017 6:06 pm
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.