How to create a TRichView at runtime

General TRichView support forum. Please post your questions here
Post Reply
Usch Wildt
Posts: 20
Joined: Fri Sep 29, 2006 11:30 am

How to create a TRichView at runtime

Post 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
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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;
Post Reply