Monsieur
Monsieur

Reputation: 9

Rich edit control: hiding the angle-bracketed link from an RTF URL

I want to display an RTF file with some links in it; the links have the RTF encoding:

{\field{\*\fldinst{HYPERLINK "http://a-link.com" }}{\fldrslt{\cf1\ul here is a link}}}

In WordPad and Word, this displays as "here is a link", underlined, as expected.

When I load the RTF into a rich edit control (RichEdit20A), it displays:

here is a link <http://a-link.com>

Is there any way to get the rich edit control to stop displaying the angle-bracketed URL after the friendly name?

Thanks!

Upvotes: 0

Views: 715

Answers (1)

Jerry
Jerry

Reputation: 4408

Use RichTextBox v5. The default in Visual Studio is v4. It fixes this problem among others.

public class RichText50W : RichTextBox
{
    [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
    static extern IntPtr LoadLibrary(string lpFileName);
    protected override CreateParams CreateParams
    {
        get
        {
            CreateParams prams = base.CreateParams;
            if (LoadLibrary("msftedit.dll") != IntPtr.Zero)
            {
                prams.ClassName = "RICHEDIT50W";
            }
            return prams;
        }
    }
}

Upvotes: 1

Related Questions