Здравствуйте, Igor_kir, Вы писали:
IK>Здравствуйте, Sinclair, Вы писали:
IK>Для поиска подойдет вариант б) — главное ухватить суть
Для него это делается так:
with RichEdit1 do
begin
{ begin the search after the current selection if there is one }
{ otherwise, begin at the start of the text }
if SelLength <> 0
then StartPos := SelStart + SelLength
else StartPos := 0;
{ ToEnd is the length from StartPos to the end of the text in the rich edit control }
ToEnd := Length(Text) - StartPos;
FoundAt := FindText(FindDialog1.FindText, StartPos, ToEnd, [stMatchCase]);
if FoundAt <> -1 then
begin
SetFocus;
// Determine the line number of the found character
LineFound:= SendMessage(Handle, EM_EXLINEFROMCHAR, 0, FoundAt);
// Determine the previous line start
if LineFound>0
then SelStart:= SendMessage(Handle, EM_LINEINDEX, FoundLine-1, 0)
else SelStart:= SendMessage(Handle, EM_LINEINDEX, FoundLine, 0);
SelLength := FoundAt-SelStart+Length(FindDialog1.FindText);
end;
end;
... << RSDN@Home 1.0 beta 6a >>