Defaultinterface in TChromium is missing - delphi

We are trying to change the builtin browser component from TWebBrowser to TChromium.
It is used mostly for displaying maps from Google and Bing. The communication from the javascript to Delphi is done with COM.
When trying to change the browser to TChromium it fails to compile this code.
if supports(fBrowser.defaultInterface, IOleObject, fOLE) then
because defaultInterface is missing from TChromium.
EDIT:
Is it possible to still communicate from javascript to Delphi with Chromium?
I'm aware of that they are not compatible and I have to rewrite code. I just want to know how to get a result from javascript to delphi. Note I am using Delphi 2007 so the extended RTTI cannot be used.
Regards
Roland Bengtsson

I never used it myself, but TChromium appears to be a wrapper around the "Chromium" web browser, while the original TWebBrowser from Delphi is a wrapper around an IE Browser.
TWebBrowser.defaultInstance gives you the COM object of the IE Browser. For the Chromium browser you can apparently use TChromium.Browser, it gives you an object of type ICefBrowser. The TChromium people were smart not to name the property defaultInstance because there's a lot of code out there casting from the return of defaultInstance to other interface types: If TChromium.Browser was named the same, the cast would compile and fail at run time. Because the IE Browser is obviously not a Chrome browser, and I doubt the Chromium browser fully implements all IE interfaces.

Using TChromium, you can invoke scripts easily via ExecuteJavaScript. And you can invoke Delphi code from scripts, which you can use to send return values back from a JavaScript function to Delphi.
See this question and my answer there about doing this using extensions.
There also seems to be work in progress for functions like EexecuteScriptAndReturnValue but as the time of writing they are not contained in the trunk.
And regarding TWebBrowser.DefaultInterface I agree with Cosmin: the best analogy is probably TChromium.Browser as you can access frames and subsequently DOM, etc. from there.

Related

Delphi TWebbrowser , google wants to update browser

i had to change code of an older Delphi application in D2007. I required a login screen that was online (with Auth0) , in wich i could read the state of the result and according to that do some license handling.
The problem is, that whenever i try to login with Google Social account , it results in an information screen that wants me to update my browser.
The app is a Win32 app , running on Win32 and Win64 devices. I had tried to work with this solution :
How to have Delphi TWebbrowser component running in IE9 mode?
But any DWORD value i give to my exe , it just doesn't help me get rid of the notification.
I've been looking to use TChromium instead of TWebBrowser, but it seems buggy to me.
Are there any other ways to deal with this issue? Thanx
If you use DWORD values mentioned in the linked topic then TWebBrowser would be working in IE9 emulation mode. And since IE9 is considered as being old various sites will advise you to update your browser.
So what you need is to make sure that TWebBrowser in your app is running in IE11 emulation mode instead.
Based on information found here:
https://msdn.microsoft.com/en-us/library/ee330730(v=vs.85).aspx
you should use DWORD value of 00011000 instead for full IE11 emulation.

TWebBrowser Cannot Open Blogspot Website

I'm using Delphi XE2 in Windows 7 64 bit, I put TWebBrowser component in a Form. I navigate it to a blogspot website, e.g:
Webbrowser1.Navigate('http://maniacpcgame.blogspot.com');
it shows JavaScript Error (HTML Parsing Error), then I turn Silent properties to True as follow:
Webbrowser1.Silent := true;
Webbrowser1.Navigate('http://maniacpcgame.blogspot.com');
But the browser cannot open the page properly (only show background image). I tried other blogspot websites and got same problem. Any solution to display blogspot website correctly in TWebBrowser?
Twebbrowser uses IEFRAME
IEFRAME depends on the version of internet explorer you are running on that computer
You can deploy IEFRAME.DLL (in c:windows/system32 )with your application so you can be sure the same version is used everywhere so you wont get inconsistencies between computers.
However newer ones wont work on XP and there are some directx requirements.
A good alternative is
Delphi Embed chromium, it makes your deployed application a lot bigger (+-15MB) but you can be very sure it works everywhere and always (windows 8 to XP) and it will always produce the same page
Also if you have to manipulate the DOM or insert javascript (to communicate with the page)
this will be easier and will work more consistently.
Here is a link for the latest version:
https://code.google.com/p/dcef3/

Downloading webpages using sessions/cookies with TDownloadUrl (Delphi)

I've been testing some samples to save webpages using TDownloadUrl, and it was really amazing, but I found some problems certain webpages, those pages cannot let to access to real content because they need to start a session o set a cookie before, so I get two situations, TDownloadUrl does...
not create/save a file with content from webpage supposedly downloaded (STATUS CODE : 5 --> dsEndDownloadData), this is because there is no cookie (STATUS CODE : 41 --> dsCookieStateDowngrade)
not save the content right instead of it saves a webpage requesting to press a link to access to content wished
Is there any way to bypass these problems using Delphi's native components, that is, no third-party components (like TEmbeddedWB)?
Thanks in advance.
Note: I'm using Delphi XE2 under WinXP with Firefox 6.0 and IE 9.0
XE2 ships with Indy 10 (which is a third-party component, but at least it is a bundled one). You can use its TIdHTTP component instead of TDownloadURL. TIdHTTP supports cookies.

Delphi,VCL... rendering web components on form

how can I render a part of website to a bitmap using delphi?
recently I've seen Raudus framework which is ExtJs binding/wrapper for delphi. However what is unique about that, it does render components to look exactly like in the browser. Simply, it works like kind of WYSIWYG designer for Javascript components in delphi IDE. I was unable to try it since I'm using delphi personal (it requires dbrtl).
However looking on the demo movie it takes some time to render the components (even after resizing them), thus I believe it is rendered through web browser rendering engine or something similar...
if anyone knows something similar but open sourced, please let me know...
thanks in advance,
m
A while ago I discovered an arcane ActiveX call: OleDraw. As it turns out, it works just great to use an embedded WebBrowser component (IWebBrowser2) to render HTML and grab the output into a bitmap.
The code may look a little like this:
uses ActiveX, OleCtrls, SHDocVw;
b:=TBitmap.Create;
try
b.Width:=SizeX;
b.Height:=SizeY;
OleDraw(WebBrowser1.OleObject,DVASPECT_CONTENT,b.Canvas.Handle,Rect(0,0,SizeX,SizeY));
b.SaveToFile(FileName);
finally
b.Free;
end;
If you're cool with how Internet Explorer renders the page, it will show properly in the TWebBrowser (built in component), and you can generate bitmaps from there.
http://delphi.about.com/od/vclusing/a/wb_scren_shot.htm
http://www.delphi3000.com/articles/article_4132.asp?SK=
Dave Baldwin's HTML display components are now freeware with source (even the Professional version) and work in Delphi up to 2006 (which means also 2007). I don't know if those will help, since you didn't specify which version of Delphi you're using.

Display Flash Web Widget in a Delphi form

I would like to display the yahoo weather widget (or any similar flash or java based widget) in a Delphi application. I freely admit I don't quite understand what would be required to make this work.
Any suggestions on how this could be accomplished would be appreciated.
I'm using Delphi 7. All of the Widgets are just HTML Code, which when I cut & paste them to my Blogger page for instance, show up and work fine. I'm not sure how to take that same html code and use it in a Delphi form to get similar results.
Detailed instructions would be appreciated as well as an explanation. Clearly I don't quite understand how this works... I only know what outcome I'd like ;-)
Thanks Rob, it wasn't a memory issue, butt he admins did take care of it as you suggested.
Mark
Basically, you want to host the SWF ActiveXObject.
http://delphi.about.com/od/graphics/l/aa040103a.htm
As mentioned above you could host Flash's active X control for a flash control.
The other option is to use an embedded webpage (possibly loaded off the local disk) using the built in Delphi TWebBrowser control to show any web content including Java or Flash controls (as long as they are installed on the client).
Hope that helps.
I have a video on embedding flash into Delphi Applications Available Here. If the widget is a flash file (.swf) it should be fairly easy. The other option (as already mentioned) is to use the Delphi TWebBrowser component.

Resources