BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TRichEdit Hyperlinks
Goto page 1, 2  Next
 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
René Rudolf
Guest





PostPosted: Wed Apr 28, 2004 1:34 pm    Post subject: TRichEdit Hyperlinks Reply with quote



Hi,

i've implemented the following code for hyperlink support in trichedit
control:
//--------------------------------------------------------------------------
-
*.cpp
//--------------------------------------------------------------------------
-
void __fastcall TForm1::FormCreate(TObject *Sender)
{
int i = RichEdit1->Perform(EM_GETEVENTMASK, 0, 0);

RichEdit1->Perform(EM_SETEVENTMASK, 0, i | ENM_LINK);
RichEdit1->Perform(EM_AUTOURLDETECT, true, 0);

RichEdit1->Lines->LoadFromFile("C:\test.rtf");
}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::WndProc(TMessage &Message)
{
if (Message.Msg == WM_NOTIFY)
{
LPNMHDR lpNmhdr = reinterpret_cast
<LPNMHDR>(Message.LParam);

if (lpNmhdr->code == EN_LINK)
{
ENLINK *lpENLink = reinterpret_cast<ENLINK
*>(lpNmhdr);

if (lpENLink->msg == WM_LBUTTONUP)
ShellExecute(Handle, "open",
RichEdit1->Text.SubString(lpENLink->chrg.cpMin + 1, lpENLink->chrg.cpMax -
lpENLink->chrg.cpMin).c_str(), NULL, NULL, SW_SHOWDEFAULT);
}
}

else
TForm::WndProc(Message);
}
//--------------------------------------------------------------------------
-
On Windows XP it works fine, but on windows 98 it doesn't happens
anything...
why...

Thanks in advance,
René


Back to top
Oren
Guest





PostPosted: Wed Apr 28, 2004 2:13 pm    Post subject: Re: TRichEdit Hyperlinks Reply with quote



it will only work for "Rich Text Edit Control", v2.0 and v3.0
as far as i know Windows 98 uses the version 1.0

so here is the problem :-)


Oren


Back to top
Hans Galema
Guest





PostPosted: Wed Apr 28, 2004 2:54 pm    Post subject: Re: TRichEdit Hyperlinks Reply with quote



René Rudolf wrote:

Quote:
i've implemented the following code for hyperlink support in trichedit
control:

void __fastcall TForm1::FormCreate(TObject *Sender)

Oh dear. Still people that use FormCreate. Better place that code
in the constructor.

Quote:
RichEdit1->Lines->LoadFromFile("C:\test.rtf");

On Windows XP it works fine, but on windows 98 it doesn't happens
anything...
why...

it doesn't happens anything... ?

Don't know why. Tried your code on WIn98SE and there are already
4 WM_NOTIFY's at startup and one EN_REQUESTRESIZE 0x0701.

Then if I click in the richedit there is a
EN_SELCHANGE 0x0702

You could be as kind as to place a rtf file that contains hyperlinks
in the attachmentgroup. I have no such file, have no idea how a
hyperlink would look and would be pleased to see one. Then I could
test also for the EN_LINK message.

Hans.

Back to top
René Rudolf
Guest





PostPosted: Wed Apr 28, 2004 3:28 pm    Post subject: Re: TRichEdit Hyperlinks Reply with quote

hi,

i don't think that there is a big difference beetween constructor
and formcreate for this program at least (i've tested both examples;
no difference)...

my programs runs on win 98 (no second edition)... Are there different
richedit control versions installed (win98, win98se)??? If true, where can
i get an update for the richedit control?

testfile?: goto wordpad or word and type in a hyperlink e.g:
http://www.microsoft.com and safe it as rtf...

regards,

René

"Hans Galema" <dontusethis (AT) dontusethis (DOT) nl> schrieb im Newsbeitrag
news:408fc41a$1 (AT) newsgroups (DOT) borland.com...
Quote:
René Rudolf wrote:

i've implemented the following code for hyperlink support in trichedit
control:

void __fastcall TForm1::FormCreate(TObject *Sender)

Oh dear. Still people that use FormCreate. Better place that code
in the constructor.

RichEdit1->Lines->LoadFromFile("C:\test.rtf");

On Windows XP it works fine, but on windows 98 it doesn't happens
anything...
why...

it doesn't happens anything... ?

Don't know why. Tried your code on WIn98SE and there are already
4 WM_NOTIFY's at startup and one EN_REQUESTRESIZE 0x0701.

Then if I click in the richedit there is a
EN_SELCHANGE 0x0702

You could be as kind as to place a rtf file that contains hyperlinks
in the attachmentgroup. I have no such file, have no idea how a
hyperlink would look and would be pleased to see one. Then I could
test also for the EN_LINK message.

Hans.



Back to top
Hans Galema
Guest





PostPosted: Wed Apr 28, 2004 4:40 pm    Post subject: Re: TRichEdit Hyperlinks Reply with quote

René Rudolf wrote:

Quote:
i don't think that there is a big difference beetween constructor
and formcreate for this program at least (i've tested both examples;
no difference)...

Indeed. It can be the same.

Quote:
my programs runs on win 98 (no second edition)... Are there different
richedit control versions installed (win98, win98se)??? If true, where can
i get an update for the richedit control?

Don't know if they are different. You could have told us the sizes
of the dll's on your system. On mine in the windowssystem32 dir:
Riched32.dll 3856 bytes
Riched.dll 241.047 bytes
riched20.dll 421.888 bytes

If you need one I can post to the attachmentsgroup.
But I think Oren is right.
Maybe you can use them from an XP system ? Why not try ?

Quote:
testfile?: goto wordpad or word and type in a hyperlink e.g:
http://www.microsoft.com and safe it as rtf...

Well that I can type in a TRichEdit too.

But that is not a hyperlink! That is an URL!

So there is nothing special on it. But then that richedit
would recognise the sequence 'http://' and underline it ?
What does it exactly?

Hans.

Back to top
Hans Galema
Guest





PostPosted: Wed Apr 28, 2004 4:42 pm    Post subject: Re: TRichEdit Hyperlinks Reply with quote

René Rudolf wrote:

Quote:
Don't know why. Tried your code on WIn98SE and there are already
4 WM_NOTIFY's at startup and one EN_REQUESTRESIZE 0x0701.

You quoted my whole post which is not needed and annoying,

But you did not even react on my testresults. Why not ?

Hans.

Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Apr 28, 2004 5:28 pm    Post subject: Re: TRichEdit Hyperlinks Reply with quote


"René Rudolf" <rene.rudolf (AT) itshop (DOT) de> wrote


Quote:
void __fastcall TForm1::FormCreate(TObject *Sender)

Do not use the OnCreate event in C++. It is a Delphi remnant that can be
triggered before the constructor, which is illegal in C++. Use the
constructor instead, or else delay the code until after the form is fully
constructed.

Quote:
void __fastcall TForm1::WndProc(TMessage &Message)
{
if (Message.Msg == WM_NOTIFY)

You should be subclassing the TRichEdit directly and then intercepting the
CM_NOTIFY message instead. The VCL wraps WM_NOTIFY and WM_COMMAND and
similar messages in such as way that components can process their own
notification messages directly, which the Parent would normally handle
instead.

Quote:
RichEdit1->Text.SubString(lpENLink->chrg.cpMin + 1, lpENLink->chrg.cpMax -
lpENLink->chrg.cpMin).c_str()

I would suggest you look at using the EM_GETTEXTRANGE message instead.

Quote:
On Windows XP it works fine, but on windows 98
it doesn't happens anything...
why...

Because TRichEdit uses the RichEdit v1.0 control, which does not support
hyperlink processing. The only reason why it works in XP is because XP
replaced the RichEdit 1.0 control with a newer one, so that any time an
application tried to create an instance of the 1.0 control, the newer one is
created instead, and it is backwards-compatible with 1.0 coding.

If you want hyperlink support in Win98, then you can't use TRichEdit. You
will have to load the RichEdit 2.0+ control yourself manually. I suggest
you go to Robert Dunn's website (http://home.att.net/~robertdunn/Yacs.html)
and get his free RichEdit component. It does all of the work for you.


Gambit



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Apr 28, 2004 5:30 pm    Post subject: Re: TRichEdit Hyperlinks Reply with quote


"René Rudolf" <rene.rudolf (AT) itshop (DOT) de> wrote


Quote:
Are there different richedit control versions
installed (win98, win98se)???

Yes. Newer versions of Windows has newer versions of the RichEdit control,
and each new version introduces new RichEdit features.

Quote:
If true, where can i get an update for the richedit control?

Not without updating the OS itself.


Gambit



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Apr 28, 2004 5:32 pm    Post subject: Re: TRichEdit Hyperlinks Reply with quote


"Hans Galema" <dontusethis (AT) dontusethis (DOT) nl> wrote


Quote:
Well that I can type in a TRichEdit too.

But that is not a hyperlink! That is an URL!

They are the same thing, as far as the underlying text itself is concerned.
The only difference between a hyperlink and a URL is that a hyperlink is
clickable, and when clicked will launch the user's default browser to the
specified URL. Newer versions of RichEdit can automatically recognize URLs
in the text and convert them to hyperlinks when displaying the text.


Gambit



Back to top
René Rudolf
Guest





PostPosted: Wed Apr 28, 2004 5:32 pm    Post subject: Re: TRichEdit Hyperlinks Reply with quote

"Hans Galema" <dontusethis (AT) dontusethis (DOT) nl> schrieb im Newsbeitrag
news:408fdcdc$1 (AT) newsgroups (DOT) borland.com...
Quote:
René Rudolf wrote:

i don't think that there is a big difference beetween constructor
and formcreate for this program at least (i've tested both examples;
no difference)...

Indeed. It can be the same.

my programs runs on win 98 (no second edition)... Are there different
richedit control versions installed (win98, win98se)??? If true, where
can
i get an update for the richedit control?

Don't know if they are different. You could have told us the sizes
of the dll's on your system. On mine in the windowssystem32 dir:
Riched32.dll 3856 bytes
Riched.dll 241.047 bytes
riched20.dll 421.888 bytes


Riched32.dll 188.416 bytes
Riched.dll 241.035 bytes
riched20.dll 431.133 bytes

so, they are really different Smile but the installed version is the same
(riched20.dll)...

Quote:
If you need one I can post to the attachmentsgroup.
But I think Oren is right.
Maybe you can use them from an XP system ? Why not try ?

yes, you can post it, but i will use this code snippet for a
commercial software. but im still searching for an offical microsoft
update pack, which i can redistribute with this software...

Quote:

testfile?: goto wordpad or word and type in a hyperlink e.g:
http://www.microsoft.com and safe it as rtf...

Well that I can type in a TRichEdit too.

But that is not a hyperlink! That is an URL!


Right. But under XP it works perfect for me. Under Win 98 the
link will be highlighted but not executed...

Quote:
So there is nothing special on it. But then that richedit
would recognise the sequence 'http://' and underline it ?
What does it exactly?

For a correct "URL" save the rtf under word. I've noticed that
word creates a correct one. If you need this rtf-file i can post it,
too.

Quote:

Hans.

René



Back to top
René Rudolf
Guest





PostPosted: Wed Apr 28, 2004 5:40 pm    Post subject: Re: TRichEdit Hyperlinks Reply with quote

"Hans Galema" <dontusethis (AT) dontusethis (DOT) nl> schrieb im Newsbeitrag
news:408fdd4e$1 (AT) newsgroups (DOT) borland.com...
Quote:
René Rudolf wrote:

Don't know why. Tried your code on WIn98SE and there are already
4 WM_NOTIFY's at startup and one EN_REQUESTRESIZE 0x0701.

You quoted my whole post which is not needed and annoying,

sorry, but it was not in my mind...

Quote:

But you did not even react on my testresults. Why not ?

on windows 98 fe its the same... but i've no win98 se for trying yet...

Quote:

Hans.

René



Back to top
René Rudolf
Guest





PostPosted: Wed Apr 28, 2004 5:45 pm    Post subject: Re: TRichEdit Hyperlinks Reply with quote

"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> schrieb im
Newsbeitrag news:408feb90 (AT) newsgroups (DOT) borland.com...
Quote:

"René Rudolf" <rene.rudolf (AT) itshop (DOT) de> wrote in message
news:408fcdb5$1 (AT) newsgroups (DOT) borland.com...

Are there different richedit control versions
installed (win98, win98se)???

Yes. Newer versions of Windows has newer versions of the RichEdit
control,
and each new version introduces new RichEdit features.

If true, where can i get an update for the richedit control?

Not without updating the OS itself.

i know, it's not the right place for this question. but where can i get an
update for all
os's, which i have to update?

Quote:


Gambit



René



Back to top
René Rudolf
Guest





PostPosted: Wed Apr 28, 2004 6:04 pm    Post subject: Re: TRichEdit Hyperlinks Reply with quote

"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> schrieb im
Newsbeitrag news:408feb27$1 (AT) newsgroups (DOT) borland.com...
Quote:

"René Rudolf" <rene.rudolf (AT) itshop (DOT) de> wrote in message
news:408fb2ff$1 (AT) newsgroups (DOT) borland.com...

void __fastcall TForm1::FormCreate(TObject *Sender)

Do not use the OnCreate event in C++. It is a Delphi remnant that can be
triggered before the constructor, which is illegal in C++. Use the
constructor instead, or else delay the code until after the form is fully
constructed.

i know, but it was only for testing purposes ;)

Quote:

void __fastcall TForm1::WndProc(TMessage &Message)
{
if (Message.Msg == WM_NOTIFY)

You should be subclassing the TRichEdit directly and then intercepting the
CM_NOTIFY message instead. The VCL wraps WM_NOTIFY and WM_COMMAND and
similar messages in such as way that components can process their own
notification messages directly, which the Parent would normally handle
instead.

RichEdit1->Text.SubString(lpENLink->chrg.cpMin + 1,
lpENLink->chrg.cpMax -
lpENLink->chrg.cpMin).c_str()

I would suggest you look at using the EM_GETTEXTRANGE message instead.

you are right. i will have a look on it...

Quote:

On Windows XP it works fine, but on windows 98
it doesn't happens anything...
why...

Because TRichEdit uses the RichEdit v1.0 control, which does not support
hyperlink processing. The only reason why it works in XP is because XP
replaced the RichEdit 1.0 control with a newer one, so that any time an
application tried to create an instance of the 1.0 control, the newer one
is
created instead, and it is backwards-compatible with 1.0 coding.

If you want hyperlink support in Win98, then you can't use TRichEdit. You
will have to load the RichEdit 2.0+ control yourself manually. I suggest
you go to Robert Dunn's website
(http://home.att.net/~robertdunn/Yacs.html)
and get his free RichEdit component. It does all of the work for you.



Nice, but i want avoid to use an extra component for the hyperlinks. But if
there are
no other possibilities i will use this one.

Quote:
Gambit



René



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Apr 28, 2004 7:01 pm    Post subject: Re: TRichEdit Hyperlinks Reply with quote


"René Rudolf" <rene.rudolf (AT) itshop (DOT) de> wrote


Quote:
i know, it's not the right place for this question.
but where can i get an update for all os's,
which i have to update?

Hyperlink support was introduced in RichEdit 2.0. The only OS that doesn't
already have RichEdit 2.0 available is Win95. However, Riched20.dll is
compatible with Win95, should you choose to install it manually. However,
TRichEdit will still not be able to use RichEdit 2.0 at all even if it is
installed. I still recommend that you get Robert Dunn's free component to
replace TRichEdit in your code altogether. Internally, it determines the
RichEdit control version available and can automatically use a newer version
if available. It derives from TCustomRichEdit, so all of your existing
TRichEdit code will work with his component. Otherwise, you will just have
to write your own RichEdit 2.0+ code manually from scratch.


Gambit



Back to top
Hans Galema
Guest





PostPosted: Wed Apr 28, 2004 7:13 pm    Post subject: Re: TRichEdit Hyperlinks Reply with quote

René Rudolf wrote:

Quote:
But if
there are
no other possibilities i will use this one.

hTen there is no need to post the dll's. Right ?

Hans

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.