I am sorry for a late answer, I overlooked this question (
The only reason for using external RVStyles in TSRichViewEdit is ability to define their properties at design time.
It does not make sense to create and assign external RVStyles in code.
You can modify text styles of built-in RVStyles (such as SRVE.RichViewEdit.Style) instead.
However, it does not make sense to create initial set of styles in SRVE.RVHeader.Styles and SRVE.RVFooter.Styles, because SRVE.RVHeader and SRVE.RVFooter contain actual document only when a header/footer is being edited. In all other time (when SRVE is not formatted, or when SRVE.RichViewEdit is being edited), headers and footers are stored in SRVE.SubDocuments[].
If you want to define initial styles in headers footers, assign properties of all SRVE.SubDocuments[].GetRVStyle.TextStyles instead.
Your code for applying changes to the selected editor is overcomplicated.
In StrikeOutAllItems, you can call:
Code: Select all
RVE.SelectAll;
RVE.ApplyStyleConversion(0);
The code in OnStyleConversion should be:
Code: Select all
procedure TForm1.SRVEStyleConversion(Sender: TCustomRichViewEdit; StyleNo,
UserData: Integer; AppliedToText: Boolean; var NewStyleNo: Integer);
var
fi: TFontInfo;
begin
fi := TFontInfo.Create(nil);
try
fi.Style := [fsStrikeOut];
NewStyleNo := ModifyTextStyle(StyleNo, fi, [rvfiStrikeout], Sender.Style);
finally
fi.Free;
end;
end;
Your code in ModifyTextStyle is overcomplicated too. You can simply write:
Code: Select all
procedure TForm1.SRVEStyleConversion(Sender: TCustomRichViewEdit; StyleNo,
UserData: Integer; AppliedToText: Boolean; var NewStyleNo: Integer);
var
fi: TFontInfo;
begin
fi := TFontInfo.Create(nil);
try
fi.Assign(Sender.Style.TextStyles[StyleNo]);
fi.Style := [fsStrikeOut];
NewStyleNo := Sender.Style.FindTextStyle(fi);
finally
fi.Free;
end;
end;