trichview.com

trichview.support




Re: load stream to richview


Return to index


Author

Message

Yernar

Posted: 12/06/2002 16:47:23


Is this what you need:


procedure TForm1.Paste_and_Convert(in_rv: TRichViewEdit);

var

  rv: TRichViewEdit;

  mem: TStringStream;

begin

  mem := TStringStream.Create('');

  try

    rv := TRichViewEdit.Create(nil);

    try

      rv.Visible := False;

      rv.Parent := Form1;

      rv.Style := RVStyle1;

      rv.Options := rv.Options + [rvoAutoCopyRTF];

      rv.PasteRTF;

      rv.SelectAll;

      rv.SaveHTMLToStream(mem, '', 'stream', '', []);

    finally

      rv.free;

    end;

    mem.Position := 0;

    in_rv.InsertText(mem.DataString);

  finally

    mem.Free;

  end

end;


procedure TForm1.Button1Click(Sender: TObject);

begin

  Paste_and_Convert(RichViewEdit1);

end;



Hope it helps.


"mjg" <[email protected]> wrote:

>

>Can anyone help with this?

>

>When a user pastes (shift-ins) rich text into my rv, I want to automatically

>convert this to it's HTML version and paste that instead.

>

>In my rv on-paste, I call

>

>procedure Paste_and_convert(in_rv:TRichViewEdit);

>var rv:TRichViewEdit; mem:TMemoryStream;

>begin

>  mem:=TMemoryStream.create;

>  rv:=TRichViewEdit.create(nil);

>  rv.options:=rv.options+[rvoAutoCopyRTF];

>  rv.PasteRTF;

>  rv.selectall;

>  rv.SaveHTMLToStream(mem,'','stream','',[]);

>  rv.free;

>  mem.Position:=0;

>  in_rv.format;

>  in_rv.InsertRTFFromStreamed(mem);

>end;

>

>Problem 1)

>It won't work if I create rv dynamically. I have to add rv onto my form

and

>reference that one in Paste_and_convert() instead.

>

>Problem 2)

>It doesn't work anyway. mem gets populated with something (ie. mem.size

changes)

>but InsertRTFFromStreamed() won't insert the mem stream into my original

>in_rv.

>

>mem contains plain acsii text (html), will InsertRTFFromStreamed() fail

if

>it's not RTF format? How can I insert plain text?

>

>TIA

>

>Mart





Powered by ABC Amber Outlook Express Converter