InsertStringTag with RC

General TRichView support forum. Please post your questions here
Post Reply
Yann
Posts: 6
Joined: Tue Jul 24, 2007 9:27 am

InsertStringTag with RC

Post by Yann »

Hello,

I use the method "InsertStringTag" to insert fields. It works great.

Is there a method to insert strings with RC (#13#10) ?

Thanks
Yann
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

InsertText, but it inserts text with empty (zero) tags.
Yann
Posts: 6
Joined: Tue Jul 24, 2007 9:27 am

Post by Yann »

will you implement this functionality ?
(an InsertText method with Tag<>0)
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

No, sorry. Because it's rarely needed.

You can use this procedure (assuming that rvoTagsArePChars in rve.Options):

Code: Select all

procedure InsertTextTag(rve: TCustomRichViewEdit; const Text,  Tag: String);
var SL: TStringList;
  i: Integer;
begin
  SL := TStringList.Create;
  SL.Text := Text;
  rve.BeginUpdate;
  for i := 0 to SL.ItemCount-1 do
     rve.InsertStringTag(SL[i], Tag);
    // for older versions of TRichView: rve.InsertStringTag(SL[i], Integer(StrNew(PChar(Tag))));
  rve.EndUpdate;
  SL.Free;
end;
If you use TRichView version older than 1.9.22, remove calls to BeginUpdate and EndUpdate.

---

Update 2011-Oct-22: changed for compatibility with TRichView 13.3+
Post Reply