Procedure MarkString(RichEdit:TRichEdit;strtomark : string);
Var
FoundAt,maxInt : integer;
begin
FoundAt:=RichEdit.FindText(strtomark,0,maxInt,[stWholeWord]);
while FoundAt <> -1 do
begin
RichEdit.SelStart := FoundAt;
RichEdit.SelLength := Length(strtomark);
RichEdit.SelAttributes.Style := [fsBold];
RichEdit.SelAttributes.Color := clRed;
RichEdit.SelText :=strtomark;
FoundAt:=RichEdit.FindText(strtomark,FoundAt + length(strtomark),maxInt,[stWholeWord]);
end;
end;
Procedure UnMarkString(RichEdit:TRichEdit;strtomark : string);
Var
FoundAt : integer;
begin
FoundAt:=RichEdit.FindText(strtomark,0,maxInt,[stWholeWord]);
while FoundAt <> -1 do
begin
RichEdit.SelStart := FoundAt;
RichEdit.SelLength := Length(strtomark);
RichEdit.SelAttributes.Style := [];
RichEdit.SelAttributes.Color := clBlack;
RichEdit.SelText :=strtomark;
FoundAt:=RichEdit.FindText(strtomark,FoundAt + length(strtomark),maxInt,[stWholeWord]);
end;
end;
Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号
执行时间: 0.036485910415649 seconds