This code must work:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var
i: integer;
begin
i := RVEFilervActionNew1.StyleTemplates.FindByName(RVHYPERLINKSTYLETEMPLATENAME);
RVEFilervActionNew1.StyleTemplates[i].ValidTextProperties := [rvfiUnderline,rvfiColor,rvfiJump,rvfiUnderlineColor];
RVEFilervActionNew1.StyleTemplates[i].TextStyle.Color := clWindowText;
RVEFilervActionNew1.StyleTemplates[i].TextStyle.UnderlineColor := clRed;
RVEFilervActionNew1.ExecuteTarget(rve);
end;
Important: changes are made before executing the action.
ValidTextPropertiesEditor was developed only for design-time support. The standard set editor in Object Inspector does not supports sets with more than 32 elements, so this property needs to be processed specially. It makes no sense to use ValidTextPropertiesEditor at runtime.
I also tried to add your code in the ActionTest demo.
I removed loading the file on start, and add after rvActionNew1.ExecuteTarget(RichViewEdit1):
Code: Select all
i := rvActionNew1.StyleTemplates.FindByName('Hyperlink');
rvActionNew1.StyleTemplates[i].ValidTextProperties :=
[rvfiUnderline,rvfiColor,rvfiJump,rvfiUnderlineColor];
rvActionNew1.StyleTemplates[i].TextStyle.Color := clWindowText;
rvActionNew1.StyleTemplates[i].TextStyle.UnderlineColor := clRed;
RVStyle1.StyleTemplates := rvActionNew1.StyleTemplates;
RichViewEdit1.RVData.DoStyleTemplatesChange;
RichViewEdit1.ApplyStyleTemplate(0);
This code works as well. You can see that it works in "Format | Styles" command. And hyperlinks inserted with "Insert | Hyperlink" are black with red underlines, as expected. The same is for auto-detected URLs.
As for pasted URLs, they may have formatting of the source document.