Using Microsoft Edge in a native Windows desktop app – part 1

This article has been updated for the new version of WebView2 that requires Microsoft Edge 82.0.488.0 or newer.

Earlier this month, Microsoft has released the new version of its Edge browser, based on the Chromium project. The new browser works on Windows 10, Windows 8.x, and Windows 7, as well as macOS, iOS, and Android. If your application display web content, you can use the new Edge browser as the rendering engine. This is made possible through the Microsoft Edge WebView2 control, currently in developer preview. In this series, I will show how you can do this in a C++ Windows desktop application.

Articles in this series:

From this series you will learn:

  • how to add the WebView2 control to your C++ desktop applications
  • navigate to pages
  • handle browsing events
  • use the asynchronous programming model of Edge
  • detect Edge installation
  • and more…

Why Microsoft Edge

Microsoft has deprecated its Internet Explorer browser and replaced it as default browser on Windows 10 with Edge. Although Internet Explorer is still available in order to maintain compatibility with older websites and intranet sites that require ActiveX and other Microsoft legacy web technologies, it is no longer developed. All efforts are focused on Edge, and the new version of Microsoft Edge is based on the Chromium project.

If you are working on existing Windows native applications that display web content or want to create new ones, you should no longer rely on Microsoft ActiveX web browser control. Using Edge and the WebView2 control is a natural choice because:

  • Edge it is the default browser for the platform.
  • WebView2 is the control that Microsoft is building for using Edge.
  • If you have the Windows automatic updates enabled (and you should) the browser is automatically updated so you do not have to trouble with keeping up with security updates.

How to get the Edge browser

If you are running on Windows 10, Edge should be updated automatically. Nevertheless, you can download it from https://www.microsoft.com/. On Windows, it works on version 10, 8, 8.1, and 7.

The new, Chromium-based Edge browser has a new icon. So you know that you have the browser if its icon looks as follows:

You can check the version of the browser if you go the Edge menu > Help and feedback > About Microsoft Edge. The minimum version that works is 82.0.488.0.

You can also use preview builds of the Microsoft Edge browser by using one of its insider channels:

  • Beta channel – major stable updates every 6 weeks
  • Dev channel – weekly updates that have been previously tested by the Edge team
  • Canary channel – updated daily

Microsoft Edge WebView2

This web control is currently in a developer preview. Its API is evolving and breaking changes appear from time to time. When breaking changes occur, you need to have both the WebView2 SDK and the Microsoft Edge (Chromium) browser updated. The breaking changes are always mentioned in the WebView2 SDK release notes.

The WebView2 control is available as a NuGet package.

The SDK is only available for Win32 C++ applications on Windows 10, 8.1, 8, and 7.

The SDK is not yet available for .NET and XAML. However, a Window Forms and WFP control for the Microsoft WebView2 web browser control is available with the webview2-control project. This is an independent project, not run by the Edge team.

Prerequisites for the demo app

In order to develop, build, and run the demo app in this series, you will need:

Documentation

You can read more about Edge and the WebView2 control from the following resources:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.