Page 1 of 1
Run-time creation of TRichView formatting wrong in display
Posted: Mon Feb 24, 2020 3:30 pm
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
Re: Run-time creation of TRichView formatting wrong in display
Posted: Mon Feb 24, 2020 6:45 pm
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];
Re: Run-time creation of TRichView formatting wrong in display
Posted: Tue Feb 25, 2020 8:41 am
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