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 

TMyRichEdit Hyperlink colors

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development)
View previous topic :: View next topic  
Author Message
George P Boutwell
Guest





PostPosted: Fri Sep 12, 2003 7:18 pm    Post subject: TMyRichEdit Hyperlink colors Reply with quote



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


Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Sep 12, 2003 8:02 pm    Post subject: Re: TMyRichEdit Hyperlink colors Reply with quote




"George P Boutwell" <gboutwel (AT) netscape (DOT) net> wrote


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:

http://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 ([url]http://www.grisoft.com)[/url].
Version: 6.0.515 / Virus Database: 313 - Release Date: 9/1/03



Back to top
George P Boutwell
Guest





PostPosted: Fri Sep 12, 2003 9:22 pm    Post subject: Re: TMyRichEdit Hyperlink colors Reply with quote



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:

http://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



Back to top
George P Boutwell
Guest





PostPosted: Fri Sep 12, 2003 9:39 pm    Post subject: Re: TMyRichEdit Hyperlink colors Reply with quote

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]
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/richedit/richeditcontrols/richeditcontrolreference/richeditstructures/charformat2.asp



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Sep 12, 2003 9:56 pm    Post subject: Re: TMyRichEdit Hyperlink colors Reply with quote


"George P Boutwell" <gboutwel (AT) netscape (DOT) net> wrote


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 ([url]http://www.grisoft.com)[/url].
Version: 6.0.515 / Virus Database: 313 - Release Date: 9/1/03




Back to top
George P Boutwell
Guest





PostPosted: Fri Sep 12, 2003 10:16 pm    Post subject: Re: TMyRichEdit Hyperlink colors Reply with quote

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



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

 
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.