I need to scan a first TRichEdit, read substrings background highlighted and copy them to another TRichEdit.
Thanks,
Armando Rodi
How to copy highlighted substrings to another RichEdit?
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
This procedure returns the highlighted text. Each text fragment is started from new line:
This procedure ignores tables. If you need to process colored text in tables, let me know.
This procedure ignores tabs. If you need to process colored tabulators, let me know.
Code: Select all
procedure GetColoredText(rv: TCustomRichView; var Text: String);
var i: Integer;
begin
for i := 0 to rv.ItemCount-1 do
if (rv.GetItemStyle(i)>=0) and
(rv.Style.TextStyles[rv.GetItemStyle(i)].BackColor<>clNone) then begin
if Text<>'' then
Text := Text+#10#13+rv.GetItemText(i)
else
Text := rv.GetItemText(i);
end;
end;
This procedure ignores tabs. If you need to process colored tabulators, let me know.