2006. október 4., szerda
How to search a TRichEdit for lines with a special pattern and change their colour
Problem/Question/Abstract:
How do I scan a TRichEdit from top to bottom and check for lines with a special pattern to change color? I only know SelStart and SelLength, but how do I select a line at a time?
Answer:
var
S: string;
i: Integer;
{ ... }
with richedit1 do
begin
lines.beginupdate;
try
for i := 0 to lines.count - 1 do
begin
S := Lines[i];
if LineShouldBeColored(S) then
begin
SelStart := Perform(EM_LINEINDEX, i, 0);
SelLength := Length(S);
SelAttributes.Color := clRed;
end;
end;
finally
SelStart := 0;
Perform(EM_SCROLLCARET, 0, 0);
lines.endupdate;
end;
end;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése