Do you need a safer, faster, and more stable way for all Internet users to experience the web?
Before the RAD Studio, Delphi and/or C++ Builder 10.4 release we used an older classic TWebBrowser component that was dependent on Microsoft’s Internet Explorer.
The current 10.4 release introduces a new TEdgeBrowser component.
The new TEdgeBrowser component in 10.4 uses Microsoft’s Edge WebView2 based on Chromium.
So, why is Chromium important?
For your customers, regarding the Internet and web experience, Chromium is a much more modern and secure HTML engine, compared to the old TWebBrowser component based on Internet Explorer, and Chromium’s Core engine is automatically updated by Microsoft for security issues. The benefit is a much better user experience, for Internet users using Delphi or C++ Builder for web applications!
Here are the steps to use the new TEdgeBrowser component with RAD Studio, Delphi and/or C++ Builder 10.4.1:
Preparing to use the Edge Browser component
The older TWebBrowser used the Operating System-supplied Internet Explorer WebBrowser browser control, so there was no preparation required to use the older TWebBrowser component. The older TWebBrowser component just worked wherever Windows has the Internet Explorer control available.
On the contrary, Microsoft Edge is not an Operating System component at this time. Because of this you need to ensure that these items are installed on your computer before you can run an application that uses it. If not, your application will throw this Edge initialization error: Failed to initialize Edge browser control:
Here are the install steps to prepare to use the Edge Browser component:
Install these items:
1. The Microsoft Edge Chromium-based browser (Canary channel version) Note: the minimum required version of the WebView2 SDK is 82.0.430.0).
2. The WebView2 control, currently available through NuGet
This applies to compiling and executing the application on your development machine, and also on the end user’s machine.
With both these installed, the new TEdgeBrowser component will function and use the Edge WebView2 browser control to render web content!
3. Install the Edge WebView2 package via GetIt (Tools | Getit Package Manager). To install the Microsoft WebView2 package, open the GetIt package manager window in the RAD Studio IDE and search for the corresponding entry: EdgeView2
After you accept the license, GetIt will download the package and copy the two WebView2 loader DLLs, for 32 and 64 bit, to the corresponding Redist folders, as the GetIt log indicates:
C:/Program Files (x86)/Embarcadero/Studio/21.0/Redist
Next, you need to copy the WebView2 loader DLL file to your target EXE directories:
Or to a folder on your path, or follow the steps in this section “Project Configuration for WebView2 loader DLLs”.
Project Configuration for WebView2 loader DLLs
Wherever you choose to place the WebView2 loader DLLs you will need to set up a post-build event to copy it into your project’s output directory.
For example,
For a Win32 target the post-build event should look something like:
copy /Y “common_DLL_folder_pathx86WebView2Loader.dll” $(OUTPUTDIR)
For a Win64 target use:
copy /Y “common_DLL_folder_pathx64WebView2Loader.dll” $(OUTPUTDIR)
This ends the preparation steps needed to use the TEdgeBrowser component.
Delphi or C++ Builder Windows VCL Application using the TEdgeBrowser component.
- On a Windows VCL Application, drop the TEdgeBrowser component on your form. Set EdgeBrowser1.Align=alClient.
- Call EdgeBrowser1.Navigate(‘https://www.embarcadero.com/’).
[crayon-67699e74113cf538810404/]
That’s it!
When you run the application:
And click on your Go to Web page Button, you should have the Edge Browser started and display your web page, like this:
Very nice!
Your Delph and C++ Builder applications now have a safer, faster, and more stable way for all Internet users to experience the web!
Lastly, when distributing your TEdgeBrowser application, there are a few ways you can ensure the WebView2 Runtime is on your client machines. Learn more about those options here.