I need to replace a Flash animation in a Delphi application. So far I have used a TShockwaveFlash component to load an SWF file. Used Adobe Animate to convert this SWF file into an HTML 5 canvas and changed some syntax for the action script.
The output from Adobe Animate is the following:
.html
.js
images/.png
How do I integrate these into my Delphi application to replace the old Flash animation? Not very experienced in web development.
We installed WebView2 and used the TEdgeBrowser component.
You can access the script part in delphi in this way:
var Script: string := componentname+'.Enable.gotoAndStop(0);';
EdgeBrowser1.ExecuteScript(Script);
Related
There are known ways of writing ActiveX plugins with Delphi, but the ActiveX itself poses a lot of limitations in browsers other than IE. So I was thinking - how to compile a plugin in NPAPI format, natively compatible with Chrome/Firefox?
Intent of the plugin is to allow to embed a VCL form into the HTML page and be able to bi-directionaly communicate with this form using JavaScript. E.g. clicking a button on a form would call JavaScript function on the page, and JavaScript functions on the page could send events to a VCL form. How this can be achieved?
There's a list of existing NPAPI wrappers for Delphi at Mozilla bugtracker: https://www.mozdev.org/bugs/show_bug.cgi?id=8708
The latest entry (NPAPI plugin framework with scripting support + demo by Yury Sidorov) offers exactly what is needed.
With that VCL Form project can be compiled into a DLL compatible with NPAPI. Manifest.json also needs to be added. Afterwards the plugin can be installed into Chrome like usual.
Following HTML code embeds the VCL form that is stored in the plugin:
<EMBED id="embed1" TYPE="application/x-delphi-demo-plugin" ALIGN=CENTER WIDTH=400 HEIGHT=300>
<script>
var embed1 = document.getElementById('embed1');
</script>
<input type=button value="Show Value" onclick='alert("Value=" + embed1.value);'>
And that is how Form can change the HTML page around it:
with Plugin.GetBrowserWindowObject do
GetObject('document')['bgColor'] := clRed;
P.S. The only fix that should be applied for modern Delphi versions - change string and PChar to AnsiString and PAnsiChar throughout the NPPlugin.pas. Or else communication with embedded form is broken.
Can someone provide some background on the TWebBrowser component with regards to HTML/CSS standards? I am puzzled why it is that despite the fact that I am using Windows 7, with IE 8 installed, that I get different rendered results when displaying a HTML file in IE8 versus what I see when the same HTML file is displayed within TWebBrowser. For instance, pseudo elements p:before and p:first-letterare totally ignored in the CSS file when the HTML file is viewed in TWebBrowser (Delphi 7), yet they are honored when the same HTML file is viewed in IE8.
Is the SHDOCVW.DLL perhaps so old that I am in affect getting IE3 rendering? I'm trying to wrap my head around why IE8 frequently renders HTML considerably different than what one gets when using TWebBrowser.
IE8 renders pages running within instances of the WebBrowser control in IE7 Standards Mode by default. The difference that you see is therefor based on the difference of the IE8 & IE7 standard.
When an executable loads an instance of the WebBrowser control it scans the registry to check whether the executable wants IE7 Standards or IE8 Standards mode.
WebBrowser Control Rendering Modes in IE8(deprecated)
WebBrowser Control Rendering Modes in IE8(Updated)
To run a WebBrowser control in IE7 Standards Mode, insert the following values into the registry:
[(HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE)\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION]
"MyApplication.exe" = dword 7000 (Hex: 0x1B58)
To run in IE8 Standards Mode insert the following registry value:
[(HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE)\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION]
"MyApplication.exe" = dword 8000 (Hex: 0x1F40)
In both of these instances, MyApplication.exe should be replaced with the name of the executable that will be running WebBrowser controls in a specified mode.
That much said, you can avoid fiddling with the registry all together.
Pages hosted in a WebBrowser control can override rendering settings by using the X-UA-Compatible meta tag to specify a rendering mode.
for example, to force IE8 TWebBrowser control to render site in IE8 standard use:
<META http-equiv="X-UA-Compatible" content="IE=8">
This can be done globally via a host-header or as a per-document edit.
the Meta tag solution might be deprecated, I would suggest you follow the registry steps.
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.
I would like to develop an interactive XFA form in LiveCycle Designer ES -2 which will support Windows as well as i-Pad. But the problem is when I open an XFA form it does not show the form rather it shows the form can not be shown(If the form has scripts within it).It only shows simple PDF documents in read only format.It also does not show the button in Acroforms.There is no interactivity related with the form.I would like to know is there any way to show the interactive PDf forms?
There is also another solution from SPZAP designed for Microsoft SharePoint and supporting XFA forms in PDFs and in some way in HTML5 compliant browsers. It has a form designer that runs in a browser (html5) and two kinds of runtime that are SharePoint integrated and are displaying PDF either in Adobe Acrobat Reader (probably Foxit in future) or converted as html5 structure (with some limitations in latter case). http://www.pdfsharepoint.com
LiveCycle Mobile ES4.0 will be able to render your forms. The look will be similar to HTML rendering.
http://www.adobe.com/products/livecycle/mobile/
The built-in pdf reader doesn't support dynamic PDF forms, Adobe doesn't have an iOS client and iPad doesn't support flash (natively).
Your only option is to render the form as HTML using LiveCycle Forms ES (server module).
You cannot render an interactive form in iPad as pdf. Reason being Apple doesn't allow any application (except web browser) to run any kind of scripts inside it (In this case Acrobat application, trying to run Javascript).
But you can render it as HTML which can be rendered in a browser and has some strip out functionality than the pdf version but its worth to try.
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.