6
6
#include < tchar.h>
7
7
#include < wrl.h>
8
8
#include < wil/com.h>
9
+ // <IncludeHeader>
9
10
// include WebView2 header
10
11
#include " WebView2.h"
12
+ // </IncludeHeader>
11
13
12
14
using namespace Microsoft ::WRL;
13
15
@@ -135,7 +137,7 @@ int CALLBACK WinMain(
135
137
// Schedule an async task to navigate to Bing
136
138
webview->Navigate (L" https://www.bing.com/" );
137
139
138
- // <Step4 >
140
+ // <NavigationEvents >
139
141
// Step 4 - Navigation events
140
142
// register an ICoreWebView2NavigationStartingEventHandler to cancel any non-https navigation
141
143
EventRegistrationToken token;
@@ -149,9 +151,9 @@ int CALLBACK WinMain(
149
151
}
150
152
return S_OK;
151
153
}).Get (), &token);
152
- // <Step4 >
154
+ // </NavigationEvents >
153
155
154
- // <Step5 >
156
+ // <Scripting >
155
157
// Step 5 - Scripting
156
158
// Schedule an async task to add initialization script that freezes the Object object
157
159
webview->AddScriptToExecuteOnDocumentCreated (L" Object.freeze(Object);" , nullptr );
@@ -162,9 +164,9 @@ int CALLBACK WinMain(
162
164
// doSomethingWithURL(URL);
163
165
return S_OK;
164
166
}).Get ());
165
- // <Step5 >
167
+ // </Scripting >
166
168
167
- // <Step6 >
169
+ // <CommunicationHostWeb >
168
170
// Step 6 - Communication between host and web content
169
171
// Set an event handler for the host to return received message back to the web content
170
172
webview->add_WebMessageReceived (Callback<ICoreWebView2WebMessageReceivedEventHandler>(
@@ -175,7 +177,7 @@ int CALLBACK WinMain(
175
177
webview->PostWebMessageAsString (message.get ());
176
178
return S_OK;
177
179
}).Get (), &token);
178
- // <Step6 >
180
+ // </CommunicationHostWeb >
179
181
180
182
// Schedule an async task to add initialization script that
181
183
// 1) Add an listener to print message from the host
0 commit comments