I have a really big problem with my vb.net Project using framwork 4.7 (so RICHEDIT50W should be used by default as suggested here).
Perhaps I should tell, I am coding with VB.net just half a year with using VS2022. Until the year 2000 I have programmed with VB6. All the years between I had no free time for coding.
And I am not sure, if this article is describing my problem - my english is not as good, since schooltime is long ago. Also I have searched everywhere, without finding a solution for that problem.
Problem: I create a test rtf-document with four regular links. This documant works fine, each click onto one of this links is calling the linkclicked-routine of the rtfbox. Then I insert a hidden hyperlink (means a link with a linkURL and another LinkDescription like "Click here" or some else) between the existing link 2 and 3
Dim linkURL as string = "https://welt.de"
Dim LinkDescription as string = "Ckick here"
Dim rtflink As String = "{\rtf1\ansi{\fonttbl{\f0\fcharset0 " & fontName & ";}}<" & "{\field{\*\fldinst{HYPERLINK " & linkURL & """}}" & "{\fldrslt{" & linkDescription & "\ul0\cf0}}}>}"
rtfbox.SelectedRtf = rtflink
This link is displayed correct in the rtfbox then. But if I move the caret onto this link, the rtfbox.selectionstart get unecpected values and the links 4 and 5 wont call the linkclicked-sub anymore. rtfbox.selectionstart shows correkt numbers until the caret is over the first char of the displayed link description.
Same problem occurs, if i create a new document in MS-Word, and reproduce this procedure. I build four links in that Word document, save this as rtf-format and open the saved rtf in my rtfbox. Works well with all four links in Word and I can open each link by ctrl+click onto one of the links.
But if I insert in MS-Word then a link with a hidden Link (other linkdescription than the linkURL) between link 2 and link 3, save this document again as rtf-format and open this Word-created document in my rtfbox, i have exactly same problen as described. Link 3 and link 4 wont call linkclicked anymore and rtfbox.selectionstart tells irregular values if the caret is place over the hidden link.
In MS-Word all five links are working fine if I ctrl-click onto one of the five links.
The problem only exists in the rtfbox, as it seems to me.
I found out, if I place either a non existing url into the linkdescription like "http://www.rest.de" or a normal text like "Click here" this problem occures. A existing URL in the description makes no problems.
Could it be possible, that the rtf-interpreter of the net-framework has a build in problem? To me it seems, the interpreter tests if in the desctiption field a regular and existing link is placed instead testing the linkURL as should be expectable .
Can someone help me to get hidden hyperlinks working in the rtfbox perhaps?
EDIT: Hi Jimi, thanks for your reply. Have not known that. In most forums an editing of existing posts is not wished.
Here a small RTF-Source-Code what explains my problem.
{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1031{\fonttbl{\f0\fnil\fcharset0 Rockwell Extra Bold;}{\f1\fnil Consolas;}} {\colortbl ;\red0\green0\blue255;\red0\green0\blue0;} {\*\generator Riched20 10.0.19041}{\*\mmathPr\mdispDef1\mwrapIndent1440 }\viewkind4\uc1 \pard {\cf1\f0\fs24{\field{\*\fldinst{HYPERLINK "https://www.example.com"}}{\fldrslt{\ul\cf1 Click here}}}}\cf1\f0\fs24 \cf2\f1\par \f0 aaa bbb\cf1\par {{\field{\*\fldinst{HYPERLINK "https://www.example.com"}}{\fldrslt{\ul\cf1 Click here}}}}\cf2\f1\fs24\par \f0 aaa bbb\cf1\par {{\field{\*\fldinst{HYPERLINK "https://www.example.com"}}{\fldrslt{\ul\cf1 Click here}}}}\cf2\f1\fs24\par \f0 aaa bbb\cf1\par {{\field{\*\fldinst{HYPERLINK "https://www.example.com"}}{\fldrslt{\ul\cf1 Click here}}}}\cf2\f1\fs24\par \f0 aaa bbb\cf1\par {{\field{\*\fldinst{HYPERLINK "https://www.example.com"}}{\fldrslt{\ul\cf1 Click here}}}}\cf2\f1\fs24\par \f0 aaa bbb\par \cf1\par \par }
If you copy that code in an texteditor and saving this with a .RTF-ending, you should see, what is my problem. When open this .rtf in MS-Word or Wordpad each link works fine. But if opening this rtf in a richtextbox, only the first two links are working and calling the link_clicked handler. The last three does nothing. If showing rtfbox.selecionstart with caret on row 0 col 0, it has 0. When moving the caret one char to the right (row 0 col 1), rtfbox.selectionstart has the value 36. That nags me, cause I need that hidden links in my project. Kind regards
Edit 2: Changing the quotes covering the url into doublequotes makes no difference - same problem as described.
The only way to get hidden links working in the richtextbox is to write a existing and correct formatted url into the "field result" (fldrstl). This if "rtfbox.detecturls = true" as well if "rtfbox.detecturls = false". To me it seems, there is a bug in the rtf-interpreter. The interpreter is testing the "field result" in same way as the field "hyperlink". What maks no sence in my oppinion.