InsertStringTag causes an exception in ActiveEditor

General TRichView support forum. Please post your questions here
Post Reply
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

InsertStringTag causes an exception in ActiveEditor

Post by vit »

Why this code causes an exception?

Code: Select all

SRVE.ActiveEditor.InsertStringTag('111', 1);
SRVE.ActiveEditor.InsertStringTag('222', 2);
P.S. SRVE.ActiveEditor = SRVE.RichViewEdit
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

Post by vit »

in case of SRVE.ActiveEditor it causes the exception too. But it works for TRichViewEdit.

In the TCustomRichViewEdit.InsertStringTag, InsertStringATag, InsertStringWTag subject of the TRichView Reference is written: Do not overuse these methods. Use InsertText when possible.

But InsertText doesn't insert text with tag.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

1) You use an old version of our components. In the new version, item tags are strings, so problems like this are not possible.
Please consider upgrading.
In the new version, this code would be:

Code: Select all

SRVE.ActiveEditor.InsertStringTag('111', '1'); 
SRVE.ActiveEditor.InsertStringTag('222', '2');
2) (in old versions) if rvoTagsArePChars is included in Options, item tags are treated as pointers to strings (allocated using StrNew functions). In TSRichViewEdit, this option is included by default. Since values 1 and 2 are not pointers, it leads to an exception.
Either exclude rvoTagsArePChars from SRVE.RichViewEdit.Options(.RVHeader.Options, .RVFooter.Options) (and you will not be able using hyperlinks), or change your code to

Code: Select all

SRVE.ActiveEditor.InsertStringTag('111', Integer(StrNew('1'))); 
SRVE.ActiveEditor.InsertStringTag('222', Integer(StrNew('2'))));
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

Post by vit »

Thank you!
mb123
Posts: 1
Joined: Wed Apr 17, 2013 12:13 am

InsertStringTag

Post by mb123 »

Sergio, Please help.

I the old rich view I used:
ReplaceText: string;
ShipperTrackingNbr: String;

DBRichViewEdit1.InsertStringTag(ShipperTrackingNbr , Integer(StrNew(PChar(ReplaceText)));

Now it fails with
The DBRichViewEdit1ReadHyperlink method referenced by DBARichViewEdit1.OnReadHyperlink has an incompatible parameter list. Remove the reference?

Please advise.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

See the list of compatibility issues in the help file:
http://www.trichview.com/help/new_in_version_14.html

Tags are strings now, not integers.

So this line must be changed to:

Code: Select all

DBRichViewEdit1.InsertStringTag(ShipperTrackingNbr , ReplaceText); 
Also, a declaration of events having tags as parameters are changed (OnReadHyperlink, OnRVControlNeeded). In existing projects, you need to change declarations of handlers of these events manually.
New parameters: http://www.trichview.com/help/idh_trich ... rlink.html
Post Reply