Solved

TWebBrowser - adding tags

Posted on 2002-05-06
8
657 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

17 Experts available now in Live!

Get 1:1 Help Now