Jump to content
pyscripter

Using the New Edge browser control

Recommended Posts

One of the new features of Delphi 10.4 was the new TEdgeBrowser component.  It is nice.  However the downside is that certain steps are needed for the use and delployment of this component:

  1.  Install Edge WebView2 package via GetIt.  This places a Dll called WebView2Loader.dll in the redist directory of Embarcadero studio (one for win32, one for win64).
  2. The appropriate WebView2Loader.dll needs to be deployed alongside your executable. (about 300Kb).  While developing you can add a post-build event to do that.
  3. Now the difficult one was that you had to replace the stable version of Edge, installed and managed by Windows, with the unstable one from the Canary Edge update channel (daily updates).  Event if you did that in your own machine, few users would accept it.

 

The new thing, that is not mentioned in the documentation, is that there is a better alternative to the third requirement.   You can use the WebView2 Runtime installer which works independently from and does not interfere with your browser, and can be safely deployed in customer sites.   Give it a try.

 

 

  • Like 2

Share this post


Link to post

Where does it put the dll? I installed it but have no idea where the dll lives. Only asking as I wanted to see if both 32 and 64bit were installed, as only a 64bit installer was offered.

Share this post


Link to post

There are several ways to ship the edge runtime:

  1. Check if the runtime is installed - If not, install it
  2. Install Edge Dev or Canary
  3. Ship your own edge dlls

Option 3 is called "fixed version distribution" and not yet available. There will be no auto-update or anything.

 

You can read more about the different options here:

Distribution of Microsoft Edge WebView2 Applications - Microsoft Edge Development | Microsoft Docs

 

PS:

9 hours ago, pyscripter said:

you had to replace the stable version of Edge, installed and managed by Windows, with the unstable one from the Canary Edge

That is not true. Nothing gets replaced, they run side by side.

Share this post


Link to post

I added this comment.

 

I added a default folder property to the class.

 

Removed:
  var hr := CreateCoreWebView2Environment(
    Callback<HResult, ICoreWebView2Environment>.CreateAs<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>(
      CreateEnvironmentCompleted));

 

Added:
 hr:=CreateCoreWebView2EnvironmentWithOptions('',PWideChar(FDefaultFolder),nil,
     Callback<HResult,ICoreWebView2Environment>.
      CreateAs<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>(CreateEnvironmentCompleted));

 

 

Share this post


Link to post

None of them worked, I also tried recommended version from http://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_TEdgeBrowser_Component_and_Changes_to_the_TWebBrowser_Component

0.9.430 which fails with access error, newer versions don't show any error messages, just creates a directory called appname.exe.WebView2 which is empty unlike previous one, which fills with a bunch of files and directories but fails.

 

image.png.b24db30406b9fc812c3711d80f80e900.png

 

I installed and copied files from fixed cab too (from https://developer.microsoft.com/en-us/microsoft-edge/webview2/ to include EmbeddedBrowserWebView.dll


I have Edge canary and stable installed, both 64 bits.
MyApps compiled and tried x86 and x64. dlls respectively, none of them works.
---
IMHO, new fixed approach (from that installer page) seems just like CEF embedded, almost like shipping your own web browser, wasting more RAM unless you take full advantage of web technologies, I'd prefer old EdgeHTML approach (aka. WebView1.0 for Win32) it works nicely for simple tasks. https://stackoverflow.com/a/52788855/537347

I wish they'd give more freedom like CEF4Delphi, specially when using system notifications (from webpage), which is still attached to its runtime executables, also audio sessions.

image.thumb.png.5c04f848b1ca418752553220d284aeb0.png

 

Both versions are like that, WebView for Win32 v1.0 and newer v2. https://github.com/MicrosoftEdge/WebView2Feedback/issues/4 CEF4Delphi as far as I remember allows to identify web notifications from your application.
image.png.b44921427e44602c4335824a6ac7470d.pngimage.png.5737726e8b8dab1cff5982f3d86aa0c1.png

While Edge's embedded gives Win32WebViewHost (for previous version), and for this new one, it shows a description for desktop notification from web viewer (in your locale) which doesn't give any way to notify users which application's the notification came from, i.e. all programs using WebView2 will notifiy (web notifications) with the same application identifier (hardcoded by Microsoft).

 

  • Sad 1

Share this post


Link to post

Hi,

 

I have tried https://stackoverflow.com/a/52788855/537347 exampe,

 

 

const
  SWebViewControlProcess = 'Windows.Web.UI.Interop.WebViewControlProcess';

type
  // Interface with functionality to interact with WebBrowser Control
  // https://docs.microsoft.com/en-us/uwp/api/windows.web.ui.iwebviewcontrol
  IWebViewControl = interface(IInspectable)
  ['{3F921316-BC70-4BDA-9136-C94370899FAB}']
    procedure Placeholder_SourceGet; safecall;
    procedure Placeholder_SourcePut; safecall;
..


 

and work fine. i can open any web sites.

 

But i can't open any local files ( and show ) , i need show a .P7M files.

 

 

 

WinS:= TWindowsString.Create('file:\\V:\DelphiXE104_PROJECT\Test\test.xml.p7m');         don't work

WinS:= TWindowsString.Create('V:\DelphiXE104_PROJECT\Test\test.xml.p7m');                 don't work

 

WinS:= TWindowsString.Create('V:\DelphiXE104_PROJECT\Test\BASE_HTML_TEMPLATE.html');               don't work

 

 

Hint ?

Share this post


Link to post
2 hours ago, Mauro Botta said:

Hint ?

Maybe create a new message thread with a clear question?

  • Like 2

Share this post


Link to post

Hi,

Has anyone got the Delphi  TEdgeBrowser ZoomFactor to work?

Setting Zoomfactor to 1.5 for instance has no effect.

Regards

Peter

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×