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

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.
Are there VCL examples somewhere?
If not, how would one go about doing it?
Where's the best place to find the core for Gecko and/or WebKit in an embeddable format?

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.

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.

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)

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.

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.

Related

Can i use XULRunner to create executable that acts like a phonegap app (WebView and fullscreen?) on the desktop (Windows/Linux/OSX)?

Story:
I have written a HTML Merge Compiler that can merge resource's/assets into one single HTML file (minify it to the max) and compiles Javascript with the google enclosure compiler. I have written this compiler to speed up loading and interpreting the code and to obfuscate the code to protect a little bit (script kiddie protection). Major reason was/is speed and to make it compact.
This is working OK with reliable results and i use this in PhoneGap applications/games. I have also written a javascript library that encapsulate all platforms that works with standard HTML/CSS without the need to change the code, it works also in the browser, with a touchscreen or without or on any device or operating system. Write once, publish many ;-). The idea around it is that is working always, always operate the same but can use device specific things when available but does never fail (when something is not there, for example a vibrate functionality).
Anyway, most frameworks (like PhoneGap) concentrate on Mobile Platforms but i want to port it also to desktop platforms like Windows, OSX and maybe Linux. For Windows I have wrote an Delphi Application that loads the HTML in a TEmbeddedWB object (is Internet Explorer actually) but the 'problem' is that it is only suitable to Windows and IE is not the fastest browser around, especially when it is embedded (do not why it is slower than the browser itself). For example, when i load the compiled code in Firefox and/or Google Chrome it is blazing fast (you do not notice it is javascript ;-)).
EDIT:
Pre release of IE10 for Windows 7 is just launched, installed it and lag is gone!
You can download it from here:
http://www.microsoft.com/en-us/download/details.aspx?id=35709
Introduction to my question:
I have tried XULRunner of Mozilla a long time ago but the first time was not a pleasure to me and also i tried it today again but can't get it to work. Get a parse error in the main xul file of the project, window is an undefined entity. ??? I create a sample project like: http://mdn.beonex.com/en/Getting_started_with_XULRunner.html
I do not know what to do about this error. Also i think documentation is not up-to-date? Most documentation is from around 2006.
The question, what i want to know:
Before i am going to waste my time (see also introduction), is it
possible to create frameless (full-screen) desktop executables with
use of XULRunner like with PhoneGap?
Is it possible to create cross-platform applications with XULRunner, i mean, does it really work seamless. Where can i find a ready-to-publish example of a XULRunner project and is it possible to load local HTML file(s) like in PhoneGap?
It is possible and allowed to access external resources?
Long story, but maybe there is somebody that have tried this before and can lead me to choose the right direction.
is it possible to create frameless (full-screen) desktop executables with use of XULRunner like with PhoneGap?
Yes. You use disablechrome attribute to remove the window frame and sizemode="maximized" to have it open full-screen. Alternatively you can use the full-screen API if you want your application to run in a normal window and only switch to full-screen mode on request.
Is it possible to create cross-platform applications with XULRunner
Yes. There are things like menus that work very differently on OS X but most of the time you don't need to care what operating system your application runs on (Windows, Linux and Mac OS X supported).
Where can i find a ready-to-publish example of a XULRunner project
See documentation for a XULRunner application example. For "ready-to-publish" you would need an installer which doesn't come with the platform.
is it possible to load local HTML file(s) like in PhoneGap?
Yes. The top-level window has to be XUL but you can use some very minimal code here - essentially a single <iframe flex="1"/> tag. You can load HTML pages into that frame then.
It is possible and allowed to access external resources?
Yes, XULRunner applications have full privileges and can access files on disk as well as web resources without any restrictions.

Can Delphi VCL project be compiled to a browser plugin?

I have a Delphi VCL application which I'm using to show some pictures and I would like to know if there is any possibility to transform it into a browser plugin (like firefox, google chrome etc ) in order to load it remotely, like a java applet.
for all of them the answer is NO. even for IE it is sometimes difficult...VCL applications means win32/64 development in general, browsers are more 'related' to web development. you can reconsider and try to resolve this by using an already existing platform which can be easily integrated into web browsers like Shockwave (yeah, I don't like to give links to wikipedia...) or another similar tool.
You can use VirtualUI from CybeleSoft to run your Windows app in a browser. You still need to set up your backend server with database etc, and make sure that some operations are blocked - you don't want someone to browse through your server files ;-)
There are options:
ActiveX plugin (you might need to enable ActiveX support in browser or use a special plugin to enable it)
NPAPI plugin (will be deprecated in Chrome in late 2014). See question: How to embed Delphi VCL form into HTML page using NPAPI?
Take a look at the samples on Raudus. It might be what you are looking for. It will be interesting for you to read this about VCL compatible component set for the web.

Desperately trying to make Watin work with IE

I have been working with Watin for about 1 week. I really wanted to make firefox work but had to give up after a day or so when seeing there was no way i could get jSSH working with Firefox 8 etc. Really wish there was a way of using Chrome or firefox i have to say
So returning reluctantly to IE I developed some automation software using Watin, however I have a persistent problem with Goto(href) where it seems as though the page never actually gets marked as complete. And although the browser navigates to the page and I can see the page fine, the call to Goto() just times out. After that point anything I try fails and it cant find the elements in the dom and I cant click anything programmatically. So I have to solve this timeout issue
I have read various articles suggesting fixes and have tried them all as far as I can see i.e. making sure I run as administrator, making sure that internet explorer enhanced security is switched off, etc.. I would really, really like to make Watin work - but right now I am about ready to give up and create a much, much simpler class with an embedded browser in my app. So stackoverflow is my last port of call. How can I stop Watin from timing out.
I am on Windows 7 Ultimate Version 6.1.7601 Service pack 1 build 7601
Visual Studio 2010
compiling as a .net 4.0 app
IE 9.0.8112.16421 with update KB2586448
I have a console app, no threads, [STAThread] on my Main entry point
This is my Visual Studio info:-
Microsoft Visual Studio 2010 Version 10.0.40219.1 SP1Rel
Microsoft .NET Framework Version 4.0.30319 SP1Rel
Microsoft Visual C# 2010 01021-532-2002102-70185
Any help will be very greatfully received.
Regards Julian
ok, so after many months of playing and fiddling the answer to my question has several parts.
Firstly. I needed to get Watin working properly as an embedded browser in a win32 application rather than as a console app. This required me to spend a huge amount of effort getting Watin embedded the way I wanted, I had problems with STATHREAD (of course), and the pop up dialog watcher, and getting the HWND of my browser into Watin to create its browser object (I used another sample on stack overflow to do this) and then I had to ensure ScriptErrorsSuppressed=true and I finally got it working. Hoorah
However, the problem I originally had all that time ago still seems to remain with Watin.2.1.0.1196 in dealing with frame sets on asda.com.
So I have just now done a svn checkout of the watin project and I am finally hoping that the latest updates I have seen will fix this problem once and for all... and Yes I am still really looking forward to Jeroen getting IE9 or indeed any other browser working with Watin. Working with IE (any flavour) sucks
WaTiN does not support IE9 fully yet as far as I know. Jeroen (the creator) is working on getting it fully compatible with IE9, but IE9 relies on new WPF components in regards to previous versions of IE, so i'm guessing this will take some work.
We suffered from several problems as well when we upgraded our WatiN tests to IE9. In the end we force our website to render everything to IE8 standards and set IE9 to IE8 rendering mode untill there is an update from watin to fully support IE9 with all its quirkcs and features.

Example source code for an ActiveX control to upload files

I'm wanting to build an ActiveX control to upload files from a user's machine on a web page.
Where can I fnd a good example or tutorial for this - I guess C++ would be my preferred language, but VB would be OK too.
ActiveX is a dead technology. I can't think of a good reason to use it instead of Silverlight.
I've actually written one in Silverlight myself. You can see it on my website if you want to take a look.

Firefox extension: native code execution?

Is it possible to write an extension that runs native, platform-dependent code? I'm an extension-newbie (what a phrase!) :), can you please point me towards good material on this subject? (good keywords to feed to Google are enough)
(I would like to put a GtkMenu in Firefox)
Edit:
I started checking out the Gecko SDK, and it's a rather big subject, and I'm not sure this is what I want.
I'd be happy with a friendly manual (which is not a raw reference, but rather some kind of tutorial on how to make extensions that utilize XPCOM (if that is the way). Good keywords are still appreciated.
Check out the Gecko SDK.
You can use it make portable C++ native code firefox extensions which I believe are XPCOM objects with JavaScript wrappers in the .xpm zip file.
I haven't tried it, but you can go the usual route and write the plugin, I mean extension, in javascript also.
Native Client doesn't quite offer the breadths of API firefox extensions offer, but it's still well worth checking out for your purposes IMHO.
Yes, you can. Witness the Cooliris extension, that makes (heavy) use of your 3D graphics card, and is Windows specific.

Resources