It is possible change a font color (or size, style, ...) programatic without use OnStyleConversion event?
I have something like this in a separate unit:
Code: Select all
procedure SetRichViewStyle(AControl: TCustomRichViewEdit; iTipo, iValor: Integer; sValor: String);
var
NewStyleNo: Integer;
FontInfo: TFontInfo;
begin
FontInfo:= TFontInfo.Create(nil);
try
FontInfo.Assign(AControl.Style.TextStyles[AControl.CurTextStyleNo]);
case iTipo of
FM_FONTBOLD: if Boolean(iValor) then FontInfo.Style:= FontInfo.Style + [fsBold]
else FontInfo.Style:= FontInfo.Style - [fsBold];
FM_FONTITALIC: if Boolean(iValor) then FontInfo.Style:= FontInfo.Style + [fsItalic]
else FontInfo.Style:= FontInfo.Style - [fsItalic];
FM_FONTUNDERLINE: if Boolean(iValor) then FontInfo.Style:= FontInfo.Style + [fsUnderline]
else FontInfo.Style:= FontInfo.Style - [fsUnderline];
FM_FONTSTRIKEOUT: if Boolean(iValor) then FontInfo.Style:= FontInfo.Style + [fsStrikeOut]
else FontInfo.Style:= FontInfo.Style - [fsStrikeOut];
FM_FONTNAME: FontInfo.FontName:= sValor;
FM_FONTSIZE: FontInfo.Size:= iValor;
FM_FONTCOLOR: FontInfo.Color:= iValor;
end;
NewStyleNo:= AControl.Style.TextStyles.FindSuchStyle(AControl.CurTextStyleNo, FontInfo, RVAllFontInfoProperties);
if NewStyleNo = -1 then
begin
AControl.Style.TextStyles.Add;
NewStyleNo:= AControl.Style.TextStyles.Count - 1;
AControl.Style.TextStyles[NewStyleNo].Assign(FontInfo);
AControl.Style.TextStyles[NewStyleNo].Standard:= False;
end;
AControl.ApplyTextStyle(NewStyleNo); /// !!! Result not expected when many items with distincts formats selected
finally
FontInfo.Free;
end;
end;
thank you
PD. Sorry for bad english