Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 672
  • Last Modified:

TWebBrowser - adding tags

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
SJohnson
Asked:
SJohnson
1 Solution
 
SJohnsonAuthor Commented:
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
 
SJohnsonAuthor Commented:
D'oh!  And I also need it to work with email addresses :)  Sorry!
0
 
ginsonicCommented:
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!

 
CesarioCommented:
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
 
intheCommented:
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
 
intheCommented:
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
 
SJohnsonAuthor Commented:
Cesario!  Great answer!  That worked perfectly.  Nice little component that one!

Thanks to everyone for their input.

Stu
0
 
SJohnsonAuthor Commented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now