Page 1 of 1

How to create a TRichView at runtime

Posted: Thu Jul 26, 2007 8:57 am
by Usch Wildt
Hi,

I would like to create and fill a document or TRichViewEdit at runtime with CB6 and save it without showing it in the gui.
Something like:

TRichViewEdit *rve = new TRichViewEdit(NULL);
TRVStyle* style = new TRVStyle(NULL);
rve->Style = style;
rve->InsertText("test");

TMemoryStream*Stream = new TMemoryStream;
rve->SaveRVFToStream(Stream, false);

But I can't get that working, I only get lots of runtime errors.

Thanks for help!

Usch

Posted: Thu Jul 26, 2007 1:20 pm
by Sergey Tkachenko
In the current version, TRichViewEdit must have a parent:

TRichViewEdit *rve = new TRichViewEdit(NULL);
rve->Visible = false;
rve->Parent = Form1;
TRVStyle* style = new TRVStyle(NULL);
rve->Style = style;
rve->Format();
rve->InsertText("test");

Besides, initial values of TRichViewEdit created at runtime are not the same as for components placed on form at designtime (for the latter, settings from the component editor are used).
Specifically, you may wish to add:

TRVFOptions RVFOptions = rve->RVFOptions;
RVFOptions << rvfoSaveTextStyles;
RVFOptions << rvfoSaveParaStyles;
rve->RVFOptions = RVFOptions;