trichview.com

trichview.support




Re: When using LoadRTFFromStream, an extra newline is added at the beginning


Return to index


Author

Message

Sergey Tkachenko

Posted: 03/17/2004 11:31:52


Yes, you must call Format before displaying document or calling any "editing

style" method (most of methods introduced in TRichViewEdit).


But in your case you clear document and then load RTF immediately.

You can use this code:



       M_Text.Clear;

       ms := TMemoryStream.Create;

       sl.Text := s;

       sl.SaveToStream(ms);

       ms.Seek(0, soFromBeginning);

       M_Text.LoadRTFFromStream(ms);

       ms.Free;

       M_Text.Format;




> Sergey Tkachenko wrote:

> > Call RichViewEdit1.Clear before LoadRTFFromStream.

> > Each RichViewEdit has one empty line initially, and LoadRTFFromStream

> > appends RTF to the end of document.

>

> Ah... the problem was something different. `Each RichViewEdit has one

> empty line initially' made that clear;

> My function looked like this:

>

>        M_Text.Clear;

>        M_Text.Format;

>        ms := TMemoryStream.Create;

>        sl.Text := s;

>        sl.SaveToStream(ms);

>        ms.Seek(0, soFromBeginning);

>        M_Text.LoadRTFFromStream(ms);

>        ms.Free;

>        M_Text.FormatTail;

>

> where M_Text is a TRichViewEdit, ms is a TMemoryStream and sl is a

> TStringList.

> Calling Format after the Clear has caused this `initial newline'.

> I thought it was required, because if I did not call it, I got an error

> message whenever entering/focusing the TRichViewEdit (Index out of

> Bounds). But that was because I can't use FormatTail if the

> TRichViewEdit wasn't formatted before.

> So removing the Format after the clear and changing FormatTail to

> Format solves the problem.

>

> Thank you every much,

>     Daniel

>





Powered by ABC Amber Outlook Express Converter