
18.01.2012, 00:05
|
 |
.
|
|
Регистрация: 18.05.2011
Адрес: Омск
Сообщения: 3,970
Версия Delphi: 3,5,7,10,12,XE2
Репутация: выкл
|
|
В "сети" и такое имеется:
Код:
function SearchForText_AndSelect(RichEdit: TRichEdit; SearchText: string): Boolean;
var
StartPos, Position, Endpos: Integer;
begin
StartPos := 0;
with RichEdit do
begin
Endpos := Length(RichEdit.Text);
Lines.BeginUpdate;
while FindText(SearchText, StartPos, Endpos, [stMatchCase])<>-1 do
begin
Endpos := Length(RichEdit.Text) - startpos;
Position := FindText(SearchText, StartPos, Endpos, [stMatchCase]);
Inc(StartPos, Length(SearchText));
SetFocus;
SelStart := Position;
SelLength := Length(SearchText);
end;
Lines.EndUpdate;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SearchForText_AndSelect(RichEdit1, 'Some Text');
end;
__________________
Je venus de nulle part
55.026263 с.ш., 73.397636 в.д.
|