Board index » cppbuilder » TMyRichEdit Hyperlink colors

TMyRichEdit Hyperlink colors


2003-09-13 03:18:07 AM
cppbuilder58
Hello,
I'm trying to write an quick little TRichEdit descendant that add
hyperlink properties and features. I can't figure out an way to change
the color of the hyperlink. I ideally, I'd like the hyperlink to change
color when it's clicked. How do I change the color of the hyperlink in
a RichEdit?
Thanks,
George
 
 

Re:TMyRichEdit Hyperlink colors

"George P Boutwell" < XXXX@XXXXX.COM >wrote in message
Quote
I'm trying to write an quick little TRichEdit descendant that add
hyperlink properties and features.
Why not just use a RichEdit v2.0 control? It has native support for URLs.
Look at the following site for information on how to use RichEdit v2.0 (and
v3.0) with BCB:
home.att.net/~robertdunn/Yacs.html
Quote
I can't figure out an way to change the color of the hyperlink.
If you're going to stick with RichEdit v1.0 (what TRichEdit natively uses),
then you'll just have to color the link the same way you color any text -
highlight the text using the SelStart and SelLength properties, and then use
the SelAttributes->Color property.
Gambit
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 9/1/03
 

Re:TMyRichEdit Hyperlink colors

Remy Lebeau (TeamB) wrote:
Quote
Why not just use a RichEdit v2.0 control? It has native support for URLs.
Look at the following site for information on how to use RichEdit v2.0 (and
v3.0) with BCB:

home.att.net/~robertdunn/Yacs.html
Hmm... Is this all that's needed for me to add to my existing class to
make it an 'RichEdit20" class?
quote from above link:
void __fastcall TRichEdit30::CreateParams(Controls::TCreateParams &Params)
{
const char RichEditModuleName[] = "RICHED20.DLL";
long int OldError;
OldError = SetErrorMode(SEM_NOOPENFILEERRORBOX);
FLibHandle = (int) LoadLibrary(RichEditModuleName);
if (FLibHandle < HINSTANCE_ERROR) FLibHandle = 0;
SetErrorMode(OldError);
// TRichEdit::CreateParams(Params);
TCustomMemo::CreateParams(Params);
// CreateSubClass(Params, "RICHEDIT");
CreateSubClass(Params, RICHEDIT_CLASS);
Params.Style = Params.Style |
(HideScrollBars ? 0 : ES_DISABLENOSCROLL) | (HideSelection ? 0 :
ES_NOHIDESEL);
}
Quote
>I can't figure out an way to change the color of the hyperlink.


If you're going to stick with RichEdit v1.0 (what TRichEdit natively uses),
then you'll just have to color the link the same way you color any text -
highlight the text using the SelStart and SelLength properties, and then use
the SelAttributes->Color property.
Maybe I missed something, but this appears not to work. Seems like it
when I tried this, as soon as I made it an link, the color reverted back
to blue...
Thanks,
George
 

{smallsort}

Re:TMyRichEdit Hyperlink colors

Remy,
Mostly cause I'm not specifically wanting to work with URLs. I want
to create an clickable word, that once that word is clicked something
happens. I don't want what is clicked to have the form
'http://blah..blah..blah', or even 'file://blah..blah..blah' (ie. I want
'George jumps.' where 'jumps' is an hyperlink and when clicked it does
something, and after that it then changes color).
How do I change the color of the link in RichEdit v2.0 or RichEdit v3.0?
I've been using RichEdit v2.0 API calls on my class and it appears to
work.
For instance, in MyRichEdit class:
TCharFormat2A Hide;
::ZeroMemory(&Hide, sizeof(Hide));
Hide.cbSize = sizeof(Hide);
Hide.dwMask = CFM_HIDDEN;
Hide.dwEffects = CFE_HIDDEN;
Perform(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&Hide);
According to MSDN [1], this is an v3.0 feature and not supported by
1.0 and it does seem to work, even with BCB's built-in class.
Remy Lebeau (TeamB) wrote:
Quote
Why not just use a RichEdit v2.0 control? It has native support for URLs.
Look at the following site for information on how to use RichEdit v2.0 (and
v3.0) with BCB:
[1]
msdn.microsoft.com/library/default.asp
 

Re:TMyRichEdit Hyperlink colors

"George P Boutwell" < XXXX@XXXXX.COM >wrote in message
Quote
Hmm... Is this all that's needed for me to add to my
existing class to make it an 'RichEdit20" class?
Why not just use Rob's premade component instead of making your own?
Quote
Maybe I missed something, but this appears not to work.
Seems like it when I tried this, as soon as I made it an link,
the color reverted back to blue...
That suggests that you are not actually using RichEdit v1.0 at all, but
RichEdit v2.0/3.0 instead with their built-in URL detection.
Gambit
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 9/1/03
 

Re:TMyRichEdit Hyperlink colors

Remy Lebeau (TeamB) wrote:
Quote
>How do I change the color of the link in RichEdit v2.0 or RichEdit

v3.0?

Disable native link support and handle it manually like you would RichEdit
v1.0.
Which leads me back to my original question. How? Everything I try
seems to not work.
Quote
>According to MSDN [1], this is an v3.0 feature and not
>supported by 1.0 and it does seem to work, even with BCB's
>built-in class.


Which OS are you using? Newer OSes actually ship with v2.0 or v3.0
installed, which emulate v1.0 when appropriate.
I'm using XP. We develop in house our own software and don't sell it to
anyone else... So we can ensure that folks not running XP, 2k, etc
still have v2 or v3 of RichEdit installed.
George