It searches for the given word in text and marks all its occurences by applying the specified text style:
Code: Select all
rve.SetSelectionBounds(0,rve.GetOffsBeforeItem(0), 0, rve.GetOffsBeforeItem(0));
while rve.SearchText(txt.Text, [rvseoDown]) do
rve.ApplyTextStyle(sncomMarked);
Code: Select all
rve.SetSelectionBounds(0,rve.GetOffsBeforeItem(0), 0, rve.GetOffsBeforeItem(0));
while rve.SearchText(txt.Text, [rvseoDown]) do
rve.ApplyStyleConversion(0);
// making the selected text white-on-green,
// other font attributes are not changed
procedure TfrmDemo7.rveStyleConversion(Sender: TCustomRichViewEdit;
StyleNo, UserData: Integer; AppliedToText: Boolean;
var NewStyleNo: Integer);
var FontStyle: TFontInfo;
begin
FontStyle := TFontInfo.Create(nil);
FontStyle.Assign(Sender.Style.TextStyles[StyleNo]);
FontStyle.BackColor := clGreen;
FontStyle.Color := clWhite;
NewStyleNo := Sender.Style.TextStyles.FindSuchStyle(StyleNo, FontStyle,
RVAllFontInfoProperties);
if NewStyleNo<0 then begin
NewStyleNo := Sender.Style.TextStyles.Count;
Sender.Style.TextStyles.Add;
Sender.Style.TextStyles[NewStyleNo].Assign(FontStyle);
Sender.Style.TextStyles[NewStyleNo].Standard := False;
end;
end;