Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed a browser object, other than IE<n>, in a Delphi application

Using the default TWebBrowser makes things easy to embed a web browser. Unfortunately the one that comes in by default is IE<n>.

I'm wondering how does one integrate a Gecko or WebKit one.

  1. Are there VCL examples somewhere?
  2. If not, how would one go about doing it?
  3. Where's the best place to find the core for Gecko and/or WebKit in an embeddable format?
like image 295
Gustavo Carreno Avatar asked Oct 02 '08 14:10

Gustavo Carreno


5 Answers

TWebBrowser is IE. It is not a plugable construction for browsers. You can have other browsers integrated in your application. See

  • http://www.adamlock.com/mozilla/
  • http://delphi.mozdev.org/articles/taming_the_lizard_with_delphi.html
  • http://ftp.newbielabs.com/Delphi%20Gecko%20SDK/

Time has moved on

This answer is from '08 and since then time has moved on. The links don't work anymore and there are probably better alternatives now.

like image 77
Lars Truijens Avatar answered Nov 07 '22 15:11

Lars Truijens


A viable alternative is CEF - Chromium Embedded Framework which encapsulates the Chromium browser which by itself encapsulates WebKit. This library is provided as plain DLLs with an exported C API.

There's a delphi interface available at code.google.com/p/delphichromiumembedded

I've been using it with my own interface implementation and works great, though not so easy to properly use as THTML or IE, but great for whoever needs a powerful and embeddable browser.

like image 35
Carlos Barbosa Avatar answered Nov 07 '22 16:11

Carlos Barbosa


Edit: Lars beat me to it, unfortunately

Well there is an ActiveX control based on the Gecko engine that tries to present an exact copy of the IWebBrowser API (which TWebBrowser uses).

You can find it here: http://www.iol.ie/~locka/mozilla/control.htm Unfortunately it looks like it hasn't been updated in a while. The last version is based on Gecko 1.7.12 and I believe Gecko is currently up to 1.9.x (used in Firefox 3)

like image 32
Otherside Avatar answered Nov 07 '22 15:11

Otherside


An alternative is THTMLViewer component. I have used this for some years.

This is now available free. the web siteis here http://pbear.com/htmlviewers.html. According to the songbeamer web site (http://www.songbeamer.com/delphi/) there is a Delphi 2009 version available.

like image 35
dcraggs Avatar answered Nov 07 '22 16:11

dcraggs


Over the last three years I have come across very little in the way of embedding Gecko in Delphi. One library that showed up fairly late in the game (for me) was the GeckoSDK project on SourceForge. I did a lot of work early on trying to make embedded Gecko work correctly in Delphi. Our first attempt at a Gecko rendering engine based internal "browser" was built using Delphi and Gecko 1.8. We have since moved on and our browser is now a XULRunner application. I have pieces of code laying around on my hard drive yet from that early attempt that I have not deleted yet.

When Mozilla releases Gecko 2.0 I think it will become a lot easier to embed in Delphi. The XPCOM object system in Gecko makes it very difficult to embed because most everything returns an NS_RESULT. Strings especially were hard.

edit: I just looked through my old bookmarks (almost all of which are dead) and searched for a new url for the Japanese language "bagel" browser based on Gecko and found it here,

http://github.com/plus7/bagel/tree/master/Legacy.

This is probably your best bet for some excellent code to start from. Unfortunately the comments in the code are Japanese and the author never responded to questions.

like image 2
TomC Avatar answered Nov 07 '22 16:11

TomC