Skip to content

Commit fe0d747

Browse files
Updates for Win32, WPF and WinForms sample apps from 105.0.1305.0
1 parent 15c9918 commit fe0d747

16 files changed

+219
-29
lines changed

SampleApps/WebView2APISample/AppWindow.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,7 @@ HRESULT AppWindow::CreateControllerWithOptions()
10061006
if (m_dcompDevice)
10071007
#endif
10081008
{
1009+
//! [OnCreateCoreWebView2ControllerCompleted]
10091010
CHECK_FAILURE(webViewEnvironment10->CreateCoreWebView2CompositionControllerWithOptions(
10101011
m_mainWindow, options.get(),
10111012
Callback<ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler>(
@@ -1018,6 +1019,7 @@ HRESULT AppWindow::CreateControllerWithOptions()
10181019
return OnCreateCoreWebView2ControllerCompleted(result, controller.get());
10191020
})
10201021
.Get()));
1022+
//! [OnCreateCoreWebView2ControllerCompleted]
10211023
}
10221024
else
10231025
{

SampleApps/WebView2APISample/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ urlFragment: WebView2APISample
1818

1919
This is a hybrid application built with the [Microsoft Edge WebView2](https://aka.ms/webview2) control.
2020

21-
![Sample App Snapshot](https://raw.githubusercontent.com/MicrosoftEdge/WebView2Samples/main/SampleApps/WebView2APISample/documentation/screenshots/sample-app-screenshot.png)
21+
![Sample App Snapshot](https://raw.githubusercontent.com/MicrosoftEdge/WebView2Samples/master/SampleApps/WebView2APISample/documentation/screenshots/sample-app-screenshot.png)
2222

2323
The WebView2APISample is an example of an application that embeds a WebView within a Win32 native application. It is built as a Win32 [Visual Studio 2019](https://visualstudio.microsoft.com/vs/) project and makes use of both C++ and HTML/CSS/JavaScript in the WebView2 environment.
2424

@@ -57,7 +57,7 @@ This hybrid approach allows you to create and iterate faster using web technolog
5757

5858
Both of these parts of the Sample App are displayed in the image below:
5959

60-
![alt text](https://raw.githubusercontent.com/MicrosoftEdge/WebView2Samples/main/SampleApps/WebView2APISample/documentation/screenshots/sample-app-layout-diagram.png)
60+
![alt text](https://raw.githubusercontent.com/MicrosoftEdge/WebView2Samples/master/SampleApps/WebView2APISample/documentation/screenshots/sample-app-layout-diagram.png)
6161

6262
1. Section One: The top part of the Sample App is a Win32 component written in C++. This part of the application takes in UI inputs from the user and uses them to control the WebView.
6363

@@ -99,7 +99,7 @@ This component handles commands from the View menu, and any functionality relate
9999

100100
This component is created when you select the Scenario/Web Messaging menu item. It implements an example application with a C++ part and an HTML+JavaScript part, which communicate with each other by asynchronously posting and receiving messages.
101101

102-
![alt text](https://raw.githubusercontent.com/MicrosoftEdge/WebView2Samples/main/SampleApps/WebView2APISample/documentation/screenshots/sample-app-webmessaging-screenshot.png)
102+
![alt text](https://raw.githubusercontent.com/MicrosoftEdge/WebView2Samples/master/SampleApps/WebView2APISample/documentation/screenshots/sample-app-webmessaging-screenshot.png)
103103

104104
#### 9. ScenarioAddHostObject.cpp and ScenarioAddHostObject.html
105105

@@ -212,7 +212,7 @@ First, navigate to the ScenarioWebMessage application within the Sample App, usi
212212

213213
The WebView should display a simple webpage titled: "WebMessage sample page". The code for this page can be found in the `ScenarioWebMessage.html` file.
214214

215-
![alt text](https://raw.githubusercontent.com/MicrosoftEdge/WebView2Samples/main/SampleApps/WebView2APISample/documentation/screenshots/sample-app-webmessaging-screenshot.png)
215+
![alt text](https://raw.githubusercontent.com/MicrosoftEdge/WebView2Samples/master/SampleApps/WebView2APISample/documentation/screenshots/sample-app-webmessaging-screenshot.png)
216216

217217
To better understand ScenarioWebMessage functionality, you can either follow the instructions on the page or the steps detailed below.
218218

SampleApps/WebView2APISample/ScriptComponent.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ bool ScriptComponent::HandleWindowMessage(
157157
}
158158
return false;
159159
}
160-
161160
//! [ExecuteScript]
162161
// Prompt the user for some script and then execute it.
163162
void ScriptComponent::InjectScript()
@@ -815,7 +814,6 @@ void ScriptComponent::AddSiteEmbeddingIFrame()
815814
}
816815
}
817816

818-
819817
void ScriptComponent::HandleIFrames()
820818
{
821819
wil::com_ptr<ICoreWebView2_4> webview2_4 = m_webView.try_query<ICoreWebView2_4>();

SampleApps/WebView2APISample/ScriptComponent.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class ScriptComponent : public ComponentBase
4646
void SendJsonWebMessageIFrame();
4747

4848
void AddSiteEmbeddingIFrame();
49-
5049
~ScriptComponent() override;
5150

5251
void HandleIFrames();

SampleApps/WebView2APISample/SettingsComponent.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ SettingsComponent::SettingsComponent(
3636
m_webView2_12 = m_webView.try_query<ICoreWebView2_12>();
3737
m_webView2_13 = m_webView.try_query<ICoreWebView2_13>();
3838
m_webView2_14 = m_webView.try_query<ICoreWebView2_14>();
39+
m_webView2_15 = m_webView.try_query<ICoreWebView2_15>();
3940
m_webViewExperimental5 = m_webView.try_query<ICoreWebView2Experimental5>();
40-
m_webViewExperimental12 = m_webView.try_query<ICoreWebView2Experimental12>();
4141
// Copy old settings if desired
4242
if (old)
4343
{
@@ -189,31 +189,31 @@ SettingsComponent::SettingsComponent(
189189
// Register a handler for the FaviconUriChanged event.
190190
// This will provided the current favicon of the page, as well
191191
// as any changes that occour during the page lifetime
192-
if (m_webViewExperimental12)
192+
if (m_webView2_15)
193193
{
194194
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
195195

196196
// Initialize GDI+.
197197
Gdiplus::GdiplusStartup(&gdiplusToken_, &gdiplusStartupInput, NULL);
198-
CHECK_FAILURE(m_webViewExperimental12->add_FaviconChanged(
199-
Callback<ICoreWebView2ExperimentalFaviconChangedEventHandler>(
200-
[this](ICoreWebView2* sender, IUnknown* args) -> HRESULT {
198+
CHECK_FAILURE(m_webView2_15->add_FaviconChanged(
199+
Callback<ICoreWebView2FaviconChangedEventHandler>(
200+
[this](ICoreWebView2* sender, IUnknown* args) -> HRESULT
201+
{
201202
if (m_faviconChanged)
202203
{
203204
wil::unique_cotaskmem_string url;
204-
Microsoft::WRL::ComPtr<ICoreWebView2Experimental12>
205-
webview2Experimental;
206-
CHECK_FAILURE(
207-
sender->QueryInterface(IID_PPV_ARGS(&webview2Experimental)));
205+
Microsoft::WRL::ComPtr<ICoreWebView2_15> webview2;
206+
CHECK_FAILURE(sender->QueryInterface(IID_PPV_ARGS(&webview2)));
208207

209-
CHECK_FAILURE(webview2Experimental->get_FaviconUri(&url));
208+
CHECK_FAILURE(webview2->get_FaviconUri(&url));
210209
std::wstring strUrl(url.get());
211210

212-
webview2Experimental->GetFavicon(
211+
webview2->GetFavicon(
213212
COREWEBVIEW2_FAVICON_IMAGE_FORMAT_PNG,
214-
Callback<ICoreWebView2ExperimentalGetFaviconCompletedHandler>(
213+
Callback<ICoreWebView2GetFaviconCompletedHandler>(
215214
[this,
216-
strUrl](HRESULT errorCode, IStream* iconStream) -> HRESULT {
215+
strUrl](HRESULT errorCode, IStream* iconStream) -> HRESULT
216+
{
217217
CHECK_FAILURE(errorCode);
218218
Gdiplus::Bitmap iconBitmap(iconStream);
219219
wil::unique_hicon icon;

SampleApps/WebView2APISample/SettingsComponent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class SettingsComponent : public ComponentBase
5454
wil::com_ptr<ICoreWebView2_12> m_webView2_12;
5555
wil::com_ptr<ICoreWebView2_13> m_webView2_13;
5656
wil::com_ptr<ICoreWebView2_14> m_webView2_14;
57+
wil::com_ptr<ICoreWebView2_15> m_webView2_15;
5758
wil::com_ptr<ICoreWebView2Settings> m_settings;
5859
wil::com_ptr<ICoreWebView2Settings2> m_settings2;
5960
wil::com_ptr<ICoreWebView2Settings3> m_settings3;
@@ -65,7 +66,6 @@ class SettingsComponent : public ComponentBase
6566
wil::com_ptr<ICoreWebView2Controller3> m_controller3;
6667
wil::com_ptr<ICoreWebView2Environment> m_webViewEnvironment;
6768
wil::com_ptr<ICoreWebView2Experimental5> m_webViewExperimental5;
68-
wil::com_ptr<ICoreWebView2Experimental12> m_webViewExperimental12;
6969
wil::com_ptr<ICoreWebView2ContextMenuItem> m_displayPageUrlContextSubMenuItem;
7070

7171
bool m_blockImages = false;

SampleApps/WebView2APISample/WebView2APISample.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup Label="ProjectConfigurations">
44
<ProjectConfiguration Include="Debug|Win32">
@@ -549,4 +549,4 @@
549549
<Error Condition="!Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.191107.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.ImplementationLibrary.1.0.191107.2\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
550550
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.1248-prerelease\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.1248-prerelease\build\native\Microsoft.Web.WebView2.targets'))" />
551551
</Target>
552-
</Project>
552+
</Project>

SampleApps/WebView2APISample/documentation/Testing-Instructions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ Test that turns off TLS error page.
745745
1. Expected: Message Box that says `Custom server certificate error support been enabled`.
746746
1. Click `OK` inside the popup dialog.
747747
1. Refresh the page.
748-
1. Expected: Web page is loaded without any errors.
748+
1. Expected: Web page is loaded without any errors.
749749
1. Go to `Settings -> Server Certificate Error -> Toogle Server Certificate Error Support`.
750750
1. Expected: Message Box that says `Custom server certificate error support been disbaled`.
751751
1. Go to `Settings -> Server Certificate Error -> Clear Server Certificate Error Actions`.
@@ -1218,9 +1218,9 @@ Verify that we don't offer saving password.
12181218
Verify that the `NewWindowRequested` event is fired when opening a link in new window from PDF.
12191219
12201220
1. Launch the sample app.
1221-
2. Load <https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf>.
1221+
2. Navigate to <https://appassets.example/SamplePDFWithLink.pdf>.
12221222
3. Go to `Scenario -> WebView Event Monitor` to begin tracking events.
1223-
4. Scroll to the second page of the PDF and right click on the first link to open the context menu.
1223+
4. Right click on the link in the PDF to open the context menu.
12241224
5. Click on 'Open link in new window'.
12251225
6. Expected: Event Monitor displays `NewWindowRequested`.
12261226

SampleApps/WebView2APISample/resource.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@
116116
#define IDM_CALL_CDP_METHOD_FOR_SESSION 243
117117
#define IDM_COLLECT_HEAP_MEMORY_VIA_CDP 244
118118
#define IDM_TOGGLE_TOPMOST_WINDOW 300
119-
120119
#define IDE_ADDRESSBAR 1000
121120
#define IDE_ADDRESSBAR_GO 1001
122121
#define IDE_BACK 1002

SampleApps/WebView2WindowsFormsBrowser/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ urlFragment: WebView2WindowsFormsBrowser
1818

1919
This is a hybrid application built with the [Microsoft Edge WebView2](https://aka.ms/webview2) control.
2020

21-
![Sample App Snapshot](https://raw.githubusercontent.com/MicrosoftEdge/WebView2Samples/main/SampleApps/WebView2WindowsFormsBrowser/screenshots/winforms-browser-screenshot.png)
21+
![Sample App Snapshot](https://raw.githubusercontent.com/MicrosoftEdge/WebView2Samples/master/SampleApps/WebView2WindowsFormsBrowser/screenshots/winforms-browser-screenshot.png)
2222

2323
The WebView2WindowsFormsBrowser is an example of an application that embeds a WebView within a Windows Forms application. It is built as a Windows Forms [Visual Studio 2019](https://visualstudio.microsoft.com/vs/) project and makes use of both C# and HTML/CSS/JavaScript in the WebView2 environment.
2424

0 commit comments

Comments
 (0)