RTF issue in TRichViewEdit when created run-time

General TRichView support forum. Please post your questions here
Post Reply
fatih
Posts: 5
Joined: Sun May 11, 2025 3:22 pm

RTF issue in TRichViewEdit when created run-time

Post by fatih »

This code works perfectly:

Code: Select all

begin
  MyRichView.Style := RVStyle1;
  OpenDialog1.DefaultExt:='rtf';
  OpenDialog1.Filter:='RTF Document (*.rtf)|*.rtf';
  if OpenDialog1.Execute then
  begin
    MyRichView.Clear;
    MyRichView.LoadRTF(OpenDialog1.FileName);
    MyRichView.Format;
  end;
end;
This loads RTF file without font styles (like plain text):

Code: Select all

var
  MyRichView: TRichViewEdit;
begin
  MyRichView := TRichViewEdit.Create(Self);
  MyRichView.Parent := Self;
  MyRichView.Align := alClient;
  MyRichView.Style := RVStyle1;

  OpenDialog1.DefaultExt:='rtf';
  OpenDialog1.Filter:='RTF Document (*.rtf)|*.rtf';
  if OpenDialog1.Execute then
  begin
    MyRichView.Clear;
    MyRichView.LoadRTF(OpenDialog1.FileName);
    MyRichView.Format;
  end;
end;
Any idea is appreciated.
standay
Posts: 288
Joined: Fri Jun 18, 2021 3:07 pm

Re: RTF issue in TRichViewEdit when created run-time

Post by standay »

Only thing I can think of is check the run-time rve RTFOptions and make sure they match the rve RTFOptions that works.

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

Re: RTF issue in TRichViewEdit when created run-time

Post by Sergey Tkachenko »

The default property values are not optimal for RTF reading.
Unfortunately, they cannot be changed because of possible compatibility problems. Instead, optimal property values are assigned when the component is placed on a form at desigtime.
Assign

Code: Select all

MyRichView.RTFReadProperties.TextStyleMode := rvrsAddIfNeeded;
MyRichView.RTFReadProperties.ParaStyleMode := rvrsAddIfNeeded;
fatih
Posts: 5
Joined: Sun May 11, 2025 3:22 pm

Re: RTF issue in TRichViewEdit when created run-time

Post by fatih »

Sergey Tkachenko wrote: Thu May 22, 2025 9:22 pm The default property values are not optimal for RTF reading.
Unfortunately, they cannot be changed because of possible compatibility problems. Instead, optimal property values are assigned when the component is placed on a form at desigtime.
Assign

Code: Select all

MyRichView.RTFReadProperties.TextStyleMode := rvrsAddIfNeeded;
MyRichView.RTFReadProperties.ParaStyleMode := rvrsAddIfNeeded;
It worked! Thank you all.
Post Reply