Jump to content
aehimself

Delphi 10.4.2 & TEdgeBrowser ( & TWebBrowser in Edge mode)

Recommended Posts

When I saw the release notes on 10.4.2 and read that TEdgeBrowser now works with the GA Edge, I got excited. I thought it means you have Windows 10 installed with Edge and it works. Well, unfortunately it's not the case, What it means is that you no longer need the Canary edition, you simply can download the runtime from Microsoft's website.

 

In all cases, you need WebView2.dll. It can come from GetIt, or you can download and extract the .NuGet package from Microsoft. You'll find the DLL under build\native folder.

 

Next, download the WebView2 Runtime. Evergreen is the easiest, it downloads and keeps a system wide runtime up-to-date. If you choose this, you are set and ready, everything should work.

 

If you choose the fixed version, things will be a bit different, as you have to tell TEdgeBrowser where to look for the files. Extract the fixed version, and simply add

 

EdgeBrowser1.BrowserExecutableFolder := 'C:\Users\user\Downloads\Microsoft.WebView2.FixedVersionRuntime.89.0.774.54.x86';

 

before the .Navigate. All set, right?

 

Nah. Embarcadero simply forgot about the TWebBrowser component, which can use Edge mode, but it does not publish this property - so normally it can only be used with Evergreen editions.

Fortunately though, this can be fixed with the usual dirty hack:

Type
 THackBrowser = Class(TWebBrowser);

procedure TForm2.FormCreate(Sender: TObject);
begin
// EdgeBrowser1.BrowserExecutableFolder := 'C:\Users\user\Downloads\Microsoft.WebView2.FixedVersionRuntime.89.0.774.54.x86';
 THackBrowser(WebBrowser1).GetEdgeInterface.BrowserExecutableFolder := 'C:\Users\user\Downloads\Microsoft.WebView2.FixedVersionRuntime.89.0.774.54.x86';
 WebBrowser1.Navigate('https://www.whatismybrowser.com/');
end;

Now, you can give your users the freedom. If they decide to download the Edge Runtime, your application will use Edge engine. If not, it still works in IE11 mode. Just don't forget to set FEATURE_BROWSER_EMULATION in the registry 🙂

 

Hope it helps others!

  • Like 2

Share this post


Link to post
4 minutes ago, aehimself said:

Embarcadero simply forgot about the TWebBrowser component, which can use Edge mode, but it does not publish this property - so normally it can only be used with Evergreen editions.

Not entirely true. There is a property "SelectedEngine" and "ActiveEngine", but as usual, there is no documentation:

SHDocVw.TWebBrowser.SelectedEngine - RAD Studio API Documentation (embarcadero.com)

 

You can, however, read a bit about it here:

Using TEdgeBrowser Component and Changes to the TWebBrowser Component - RAD Studio (embarcadero.com)

 

PS: As far as I remember, if you chose to ship your own, fixed runtime, you can also set an environment variable in your process and the Edge runtime will pick it up:

Globals | Microsoft Docs

  • Like 1

Share this post


Link to post

Old post, yeah, but current topic.

 

I decided to give Edge WebView2 another chance, since I have read here and there something.

In the end I've lost half a day without success, that is really bitter.

Trying our all this Canary, GetIt, Runtime stuff in myriad ways, nothing is really complete still.

 

So I'll better stay with Cef4D then, or does anybody have a roadmap or real foolproof solution ?

I give up (again).

 

 

Share this post


Link to post

TEdgeBrowser works, and it works well. The whole reason I posted this topic way before is because it's not straightforward at all... at least not for me 🙂

What issues you ran into? What does not work? What steps did you take already?

Share this post


Link to post

I have been shipping one of our Delphi applications with the WebView2 runtime for months now. It really does work fine.

 

The easiest mistakes are

  1. Forgetting to ship the needed dll
  2. Forgetting to install (or ship) the runtime or needed beta browser version
  3. Putting the application in a write-protected folder without telling the runtime where it can write

What exactly is your problem?

Share this post


Link to post

I installed the WebView2 loader via GIT, and yes I copied the right 32/64 Bit DLL version close to the EXE.

First of all, I am not sure if the normal, Windows 10 Edge works (as chromium), it canot be used in EdgeMode in my VM.

So I thought OK, this is not yet ready, so I have to install the "Canary" channel separately, still not working.

Then I read about the "Runtime" version, and installed that too, still not working.

 

You are right, I considered 32/64 Bit issues again (my EXE is 32), and 'I re-installed all Loader 32/64, Canary 32/64 und Runtime 32/64 accordingly, still not working.

I thought, maybe a reboot needed, still not working.

 

Anyhow, thats too much hazzle anyway, so I will stay with Cef4Delphi, it is more advanced in my opinion.

I wanted to check if Edge is comparable meanwhile, I'm afraid it's not.

The goal was to get rid of the 200MB Chromium DLL's, but the Edge DLL's are not less anyway (only should be better integrated in the OS).

 

I can work with TWebBrowser in normal mode, but its not able to switch to EdgeMode.

If I use TEdgeBrowser, then I cannot work either, so I ask myself what am I missing here ?

Regarding the VM, I have some VC redistributables, and usually the latest Win10 version, .NET version, so what else could go wrong ?

 

 

Edited by Rollo62

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

×