Run-time creation of TRichView formatting wrong in display

General TRichView support forum. Please post your questions here
Post Reply
tijensen
Posts: 2
Joined: Mon Feb 24, 2020 3:21 pm

Run-time creation of TRichView formatting wrong in display

Post by tijensen »

Using RV 18.2, when I create a TRichView by clicking a button, it displays bad formatting. If I place a TRichView on a form, it displays correctly.
Steps: Create TRvStyle, create TRichView, attach Style, call LoadRTF, call Reformat.

What are the requirements to instantiate a TRichView run-time?

Does anyone have a sample that does that?

I tried to attach a sample, but the forum says the file is too large (0.9MB)...


Regards,

Thomas
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Run-time creation of TRichView formatting wrong in display

Post by Sergey Tkachenko »

Initial values of some properties are different for TRichView components created at runtime and placed on a form at designtime.

Initial values of properties for components created at designtime can be set using a component editor (right click TRichView in Delphi IDE and choose "Settings" in the popup menu).
Initial values of properties for components created at runtime are different, I cannot change them for a backward compatibility reason.

To load RVF and RTF properly, I suggest making the following property changes:

Code: Select all

var
  rv: TRichView;
begin
  rv := TRichView.Create(Self);
  rv.Style := TRVStyle.Create(rv);
  rv.RTFReadProperties.TextStyleMode := rvrsAddIfNeeded;
  rv.RTFReadProperties.ParaStyleMode := rvrsAddIfNeeded;
  rv.RVFOptions := rv.RVFOptions + [rvfoSaveTextStyles, rvfoSaveParaStyles, 
    rvfoLoadTextStyles, rvfoLoadParaStyles, 
    rvfoSaveLayout, rvfoLoadLayout, 
    rvfoSaveBack, LoadBack];
tijensen
Posts: 2
Joined: Mon Feb 24, 2020 3:21 pm

Re: Run-time creation of TRichView formatting wrong in display

Post by tijensen »

Thanks Sergey, it works after I applied your suggestions.
I couldn't find rvfoLoadTextStyles and rvfoLoadParaStyles, but it works without that!

Since you already have a Manual, you could add a section to it named "Programmactically creating RichView components"...

Thanks,

Thomas
Post Reply