Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using RichEdit 2.0/3.0 and detecting URLs & email

11 views
Skip to first unread message

A.Gil

unread,
Nov 27, 2003, 4:35:43 PM11/27/03
to
Hi.. I'm making some tests to detect URL typing(and email addresses) in
a richedit component in my application.
Looking at Google, and Robert Dunn
website(http://home.att.net/~robertdunn/Yacs.html), I know that the
TRichEdit componente in BCB uses RichEdit 1.0 and that i must use
version 2.0 or 3.0 to achieve this(and other new options in richedits:
zoom, etc...)

My code for loading the library is (in the form's constructor)

HINSTANCE hInst;
hInst = LoadLibrary("riched20.dll");
if(!hInst)
ShowMessage("not loaded");

Is this fine? (I've never loaded a DLL before, just a newbie)

I found an article in BCB Developer's Journal about detecting
URL'.(showed below).This works fine, but can be and also an email
address detected? Is possible? How could this be done?
Thank you very much.

(Sorry for my poor english)
A.Gil


The code in the example is:

(In the form's constructor)
unsigned mask = SendMessage(RichEdit1->Handle,
EM_GETEVENTMASK, 0, 0);
SendMessage(RichEdit1->Handle, EM_SETEVENTMASK,
0, mask | ENM_LINK);
SendMessage(RichEdit1->Handle, EM_AUTOURLDETECT,
true, 0);

RichEdit1->Text = "The Bridges Publishing Web"
" Site is located at www.bridgespublishing.com. Check"
" it out.";

--------------------------------------------
void __fastcall TForm1::WndProc(
Messages::TMessage &Message)
{
if (Message.Msg == WM_NOTIFY)
{
if (((LPNMHDR)Message.LParam)->code ==EN_LINK)
{
ENLINK* p = (ENLINK *)Message.LParam;
if (p->msg == WM_LBUTTONDOWN)
{
SendMessage(RichEdit1->Handle,
EM_EXSETSEL, 0, (LPARAM)&(p->chrg));
ShellExecute(Handle, "open",
RichEdit1->SelText.c_str(), 0, 0,
SW_SHOWNORMAL);
}
}
}

TForm::WndProc(Message);
}

Remy Lebeau (TeamB)

unread,
Nov 27, 2003, 5:19:05 PM11/27/03
to
"A.Gil" <silo...@hotmail.com> wrote in message
news:3fc6...@newsgroups.borland.com...

> My code for loading the library is (in the form's constructor)

Why not just use Robert's TaeRichEdit component? It already does all the
work for you.

> Is this fine? (I've never loaded a DLL before, just a newbie)

That will load the DLL, but that is not enough to actually use the newer
controls. You still have to explitically instantiate the desired control
via CreateWindow() just like any other windowed control. You can't
magically make a standard TRichEdit use REv2 or REv3 instead of REv1 by just
loading the library alone.

> This works fine, but can be and also an email address detected?

EM_AUTOURLDETECT supports many different URL types, including email
addresses:


http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/richedit/richeditcontrols/richeditcontrolreference/richeditmessages/em_autourldetect.asp
Or:
http://tinyurl.com/wtph


Gambit


A.Gil

unread,
Nov 27, 2003, 5:25:05 PM11/27/03
to
>
> Why not just use Robert's TaeRichEdit component? It already does all the
> work for you.

I'll try it.

Thanks for your quick answer, Remy.
A.Gil

0 new messages