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 1

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

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

×