I have been able to download and build the sample projects from Microsoft. I can run the Win32 project and it displays a WebView2 object in the View and appears functional.
For my situation I want to use a CDialog as the parent for the WebView2 control and I can't work out how to do this. When I follow the instructions here it is based on a View style object. In the instructions it says:
Step 3 - Create a single WebView within the parent window
Add a WebView to the main window.
I get lost here and don't knwo how to add the control to my basic CDialog project.
Thank you for your direction on how to deal with this.
This alternative tutorial helped me. I downloaded the sample project, compiled it and it worked. Again, it was based on a application derived from a
CView. However, I have managed to work out the principles required.No doubt more will be involved as I continue to tweak the test application I am making.
Microsoft.Web.WebView2NuGet packageMicrosoft.Windows.ImplementationLibraryNuGet packageInitInstanceto useCoInitialize.ExitInstancehandler and callUnCoinitialize.For testing purposes I simply used the dimensions of my dialog. Begin by adding a variable to your dialog class:
Then, in
OnInitDialogyou can do something like this:For the test, I also added the
OnSizehandler:The heart of this is the
CWebBrowserclass. This is available in the linked tutorial and all I did was adjust theSetParentViewmethod so that it accepted aCWndpointer instead.Oh, and you add
DestroyWindowto the dialog class:CWebBrowserHeaderCWebBrowserSourceIt works. One final comment, atleast for current ooperating systems... Make sure you have installed the WebView2 Runtime.