Solved Links in Rich Edit controls

forum.sourcecode (2000-2005) & forum.td.sourcecode (2005-2010)
Rafael Kuzminski

Links in Rich Edit controls

Post by Rafael Kuzminski » 23 Jan 2007, 17:12

 Posted by:  Rafael Kuzminski 

I'm trying to create a link in my Rich Edit control without luck. Has anyone
managed to do that? The same way you create a "hyperlink" in e.g. Word,
where you enter the URL address and a title for it. The result should be
only the title being shown and once it hovered upon, a "hand" should appear
telling users that it's a clickable link. When clicked, user should navigate
to whatever the URL it's holding.

Example:

This is a Link.

Description:

"Behind" the Link is an URL that should NOT be visible, but used for
navigation when the Link is clicked upon.

Any hints?

Regards

/Rafael

Jeff Luther
Site Admin
Site Admin
United States of America
Posts: 2370
Joined: 04 Mar 2017, 18:34
Location: Palm Springs, California

Re: Links in Rich Edit controls

Post by Jeff Luther » 23 Jan 2007, 17:28

 Posted by:  Jeff Luther 

I have a code sample on my info. page link below that shows how to create a
link in TD. It is not for a RE control, but perhaps you can apply it there.
The sample is called: "URL - adding a URL link to your form or dialog"

Best Regards,
Jeff @ PC Design
info: www.JeffLuther.net/gupta/

Christian Astor

Re: Links in Rich Edit controls

Post by Christian Astor » 23 Jan 2007, 20:44

 Posted by:  Christian ASTOR 


CFE_LINK, EN_LINK

Rafael Kuzminski

Re: Links in Rich Edit controls

Post by Rafael Kuzminski » 24 Jan 2007, 08:41

 Posted by:  Rafael Kuzminski 

Hi!

I tried that one but the result was that only "known" links (as www, ftp
etc) became "active". The URL address was always underlined but never
"changed" to a custom defined one. What I like to do is to create a "custom"
link, showing a text section but NOT the URL address, as all links are shown
in Web.

Example:

Text to show: "Click here!"

When clicked, the URL is used to open the http://www.guptaworldwide.com/ .
The URL is however never shown.

Is that possible?

I tried with the HYPERLINK tag, as you might find in the RTF text (see
example below). When using it however, the Rich Edit Control shows the
result as "Click Here! " and only the URL
section was active(www...), not the text section (Click Here!).

Example:

Code: Select all

{\rtf1\ansi\ansicpg1252\deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fprq2\fcharset0
Times New Roman;}}
{\colortbl ;\red0\green0\blue255;}
\viewkind4\uc1\pard\f0\fs24{\field{\*\fldinst{HYPERLINK
"http://www.guptaworldwide.com/" }}{\fldrslt{\cf1\ul Click
here!}}}\cf0\ulnone\f0\fs24\par
}
Is the HYPERLINK a reserved tag only used by MS controls found in e.g.
WordPad, Word etc? Or how do I accomplish that in a simple Rich Edit
control?

/R

Rafael Kuzminski

Re: Links in Rich Edit controls

Post by Rafael Kuzminski » 24 Jan 2007, 08:51

 Posted by:  Rafael Kuzminski 

Thanks!

However, I need to have that link inside a section of a Rich Edit control so
I can't use it. Thanks anyway for the help.

/R

Rafael Kuzminski

Re: Links in Rich Edit controls

Post by Rafael Kuzminski » 24 Jan 2007, 09:06

 Posted by:  Rafael Kuzminski 

I can address another issue, that could be a solution (if possible to solve)
to my entire problem:

Activating the EM_AUTOURLDETECT on the Rich Edit control will automatically
detect all "known" URL's.

Example:

Set nEventMask = SalSendMsg( RichEdit, EM_GETEVENTMASK, 0, 0 )

Call SalSendMsg( RichEdit, EM_SETEVENTMASK, 0, nEventMask | ENM_LINK )

Call SalSendMsg( RichEdit, EM_AUTOURLDETECT, TRUE, 0 )

This will automatically detect the following URL's:

http:

file:

mailto:

ftp:

https:

gopher:

nntp:

prospero:

telnet:

news:

wais:

But if I create a custom URL protocol like "abc:" (which I have), the Rich
Edit control will not recognize it as a "known" URL prefix and therefore,
not detect it. The OS will however. If I write abc://DoSomething in a
explorer window, my application is started and things are done accordingly.

Is it possible to "register" my prefix in the Rich Edit control so it
detects it as a URL?

Regards

/R

Christian Astor

Re: Links in Rich Edit controls

Post by Christian Astor » 24 Jan 2007, 09:25

 Posted by:  Christian ASTOR 


No, CFE_LINK is for any text.

Rafael Kuzminski

Re: Links in Rich Edit controls

Post by Rafael Kuzminski » 24 Jan 2007, 16:53

 Posted by:  Rafael Kuzminski 

Ok, I misunderstood that. Thanks for the help.

/R

Return to “td.sourcecode”

Who is online

Users browsing this forum: [Ccbot] and 0 guests