1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| procedure TForm1.Button2Click(Sender: TObject);
var FoundAt: LongInt;
StartPos, ToEnd, PosActu, Fin: Integer;
begin
with RichEdit1 do
begin
SetFocus;
PosActu:=SelStart;
StartPos:=perform(EM_LINEINDEX,perform(EM_GETFIRSTVISIBLELINE,0,0),0);
Fin:=StartPos+400;
FoundAt := FindText('t',StartPos,Fin, [stMatchCase]);
while FoundAt <> -1 do
begin
SelStart:=FoundAt;
SelLength:=length('t');
SelAttributes.Color:=clRed;
FoundAt := FindText('t',FoundAt+length('t'),Fin-FoundAt, [stMatchCase]);
end;
SelStart:=PosActu;
end;
end; |
Partager