Solved

TWebBrowser - adding tags

Posted on 2002-05-06
8
658 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now