Solved

TWebBrowser - adding tags

Posted on 2002-05-06
8
659 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 100
ddeman not working in activex 3 103
Strange behavior when a form is closed 6 57
Performance of SQL statement 37 111
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

773 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