How to iterate all words in TRichView ?
Posted: Tue Jun 24, 2008 2:08 am
Hi.
I am using TRichView component. I want to iterate all the words in the content, but am not able to do this, as GetItemText returns the paragraph. I need each individual word, because I am doing a find/replace operation.
Please help me how to do it. Thanks!
Regards,
NotraDamus
Here is my code:
I am using TRichView component. I want to iterate all the words in the content, but am not able to do this, as GetItemText returns the paragraph. I need each individual word, because I am doing a find/replace operation.
Please help me how to do it. Thanks!
Regards,
NotraDamus
Here is my code:
Code: Select all
var
richviewedit1 : TRichView;
richviewstyle1 : TRVStyle;
c,d :integer;
s:string;
begin
richviewedit1 := TRichView.Create(nil);
richviewstyle1 := TRVStyle.Create(nil);
richviewedit1.Parent:=application.MainForm;
richviewedit1.Style:=richviewstyle1;
emlmsg.MsgBody.Position:=0;
richviewedit1.LoadRTFFromStream( emlmsg.MsgBody );
richviewedit1.Format;
for c := 0 to richviewedit1.itemCount - 1 do
begin
if richviewedit1.GetItemStyle(c) >= 0 then
begin
for d := 0 to replaceables.FindList.Count - 1 do
begin
if trim(richviewedit1.GetItemText(c)) = trim(replaceables.FindList[d]) then
begin
richviewedit1.SetItemText(c, replaceables.replaceList[d]);
richviewedit1.Format;
end;
end;
end;
end;
emlmsg.MsgBody.Position:=0;
richviewedit1.SaveRTFToStream( emlmsg.MsgBody, false );
richviewedit1.Parent:=nil;
richviewedit1.Free;
end;