Solved

TWebBrowser - adding tags

Posted on 2002-05-06
8
664 Views
Last Modified: 2010-04-04
Yeah, stupid title I know, but I don't know how use to start.

I've written a little chat program in D5 which used to use a TRichEdit for the sent and recieved messages.  The problem is, if we send a URL, obviously we can't click on it.

So, I decided to create a memory stream from the sent message and stream it into the web browser component.  However, if I send: Please visit http://www.fredbloggs.com, I get it as plain text, not as a URL.  What I want to know is, is there a way I can make the component automatically generate the URL, or is there an easy way I can convert the provided string to contain a clickable link.  So:

Please visit http://www.fredbloggs.com would become Please visit <a href="http://www.fredbloggs.com">http://www.fredbloggs.com</a>

Any help would be appreciated.

Cheers!

Stu
0
Comment
Question by:SJohnson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 1

Author Comment

by:SJohnson
ID: 6992808
Oh yeah, this should work for all types of URLs : ftp, http, www, https.  I'm not worried about ones that look like fredbloggs.com though as that's pretty difficult to figure out if it's a URL or just a badly punctuated sentence.
0
 
LVL 1

Author Comment

by:SJohnson
ID: 6992811
D'oh!  And I also need it to work with email addresses :)  Sorry!
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6993048
interested
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Accepted Solution

by:
Cesario earned 50 total points
ID: 6993306
You can use TRichedit98:
By Alexander Obukhov. Rich edit control with extended capabilities. Extra formatting properties (highlight, indices, line spacing and so on), URL detection, multilevel undo/redo, support for Unicode strings.

http://www.torry.net/vcl/edits/rich/richedit98.zip


TRichView (freeware) v.0.5.2
By Sergey Tkachenko. TRichView components can contain:
text with various fonts and colors (font styles are concentrated in TRVStyle component and can be edited at run time or at design time by special property editor),
hypertext,
pictures (bitmaps, icons, metafiles),
pictures from Image Lists (they also can be hypertext links),
any Delphi components (and they will work as usual).
background bitmap (it can be tiled or stretched, scrolled or not). You can hide or show vertical scrollbar, and you have full control over vertical scrolling.
printing (with new TRVPrint component) (limitation: inserted components are not printed in this version)
saving to text file or html file (limitation: images are saved as windows bitmaps so this html file can be viewed only in browsers wich support this format (MS IE, for example); but you can override virtual method for picture saving)
ability to get word right- or double-clicked
ability to remove some lines
ability to add new lines without reformatting of whole document (IRC-style autoscroll)
http://www.torry.net/vcl/edits/rich/richview.zip


good luck
0
 
LVL 17

Expert Comment

by:inthe
ID: 6995410
stu,
i agree with cesario that you need different component but i would  use TDHtmlEdit instead (just import it the same as twebbrowser)as basically you need a mini html editor and thats what it is.

add the following code to a new form with a twebbrowser and a tdhtmledit .press f9 then type something in the dthemledit and press button.viola

procedure TForm1.FormCreate(Sender: TObject);
begin
webbrowser1.navigate('about:blank');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
webbrowser1.oleobject.document.write(dhtmledit1.DocumentHTML);
end;



once happy write dhtmledit1.DocumentHTML to your stream..
Regards Barry
0
 
LVL 17

Expert Comment

by:inthe
ID: 6995414
ps,
add smilies to your app :-),
these will transfer to webbrowser also

var
ov : olevariant;
begin
opendialog1.execute; //pick a gif.jpeg
ov := dhtmledit1.DOM.Selection.CreateRange;
ov.pasteHTML('<image src="' + opendialog1.Filename + '">');
end;
0
 
LVL 1

Author Comment

by:SJohnson
ID: 6998472
Cesario!  Great answer!  That worked perfectly.  Nice little component that one!

Thanks to everyone for their input.

Stu
0
 
LVL 1

Author Comment

by:SJohnson
ID: 6998475
Barry,

LOL.  Great idea, although a little too complex for what I'm doing.  This little app is just for work to let people know that someone has called for them etc.  However, that's something I may consider adding at a later date.

Cheers!

Stu
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question