annotate win/edge.cpp @ 2041:638be5b17715

Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge. Previously we created an environment for each edge HTML widget, and one during detection.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 24 Nov 2019 06:59:52 +0000
parents 89d62197124b
children 0d8b898b03e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1 /* edge.cpp
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2 *
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3 * Allows dw_html_new() to embed a Microsoft Edge (Chromium) browser.
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4 *
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5 * Requires Windows 10, 8 or 7 with Microsoft Edge (Chromium) installed.
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6 *
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7 * Only included when BUILD_EDGE is defined, will fall back to embedded IE.
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8 *
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9 * Currently only buildable with Visual Studio since it requires the EDGE
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10 * SDK which is currently distributed as a nuget package.
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11 */
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12 #include "dw.h"
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
13 #include "webview2.h"
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
14 #include <wrl.h>
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
15
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
16 using namespace Microsoft::WRL;
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
17
2034
89d62197124b Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2033
diff changeset
18 #define _DW_HTML_DATA_NAME "_dw_edge"
89d62197124b Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2033
diff changeset
19 #define _DW_HTML_DATA_LOCATION "_dw_edge_location"
89d62197124b Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2033
diff changeset
20 #define _DW_HTML_DATA_RAW "_dw_edge_raw"
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
21
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
22 extern "C" {
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
23
2018
663d79f28e46 Win: Fix dw_html_javascript_run() when using embedded IE browser widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2015
diff changeset
24 /* Import the character conversion functions from dw.c */
2034
89d62197124b Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2033
diff changeset
25 LPWSTR _myUTF8toWide(const char *utf8string, void *outbuf);
89d62197124b Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2033
diff changeset
26 char *_myWideToUTF8(LPCWSTR widestring, void *outbuf);
2018
663d79f28e46 Win: Fix dw_html_javascript_run() when using embedded IE browser widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2015
diff changeset
27 #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL)
663d79f28e46 Win: Fix dw_html_javascript_run() when using embedded IE browser widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2015
diff changeset
28 #define WideToUTF8(a) _myWideToUTF8(a, a ? _alloca(WideCharToMultiByte(CP_UTF8, 0, a, -1, NULL, 0, NULL, NULL)) : NULL)
663d79f28e46 Win: Fix dw_html_javascript_run() when using embedded IE browser widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2015
diff changeset
29 LRESULT CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2);
2022
28809bf17957 Win: Switch to using _wcsicmp() from CompareStringOrdinal() for increased compatibility.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2018
diff changeset
30 BOOL CALLBACK _free_window_memory(HWND handle, LPARAM lParam);
2041
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
31 IWebView2Environment *DW_EDGE_ENV = NULL;
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
32
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
33 /******************************* dw_edge_detect() **************************
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
34 * Attempts to create a temporary Edge (Chromium) browser context...
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
35 * If we succeed return TRUE and use Edge for HTML windows.
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
36 * If it fails return FALSE and fall back to using embedded IE.
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
37 */
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
38 BOOL _dw_edge_detect(VOID)
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
39 {
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
40 CreateWebView2EnvironmentWithDetails(nullptr, nullptr, nullptr,
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
41 Callback<IWebView2CreateWebView2EnvironmentCompletedHandler>(
2041
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
42 [](HRESULT result, IWebView2Environment* env) -> HRESULT {
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
43 // Successfully created Edge environment, return TRUE
2041
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
44 DW_EDGE_ENV = env;
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
45 return S_OK;
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
46 }).Get());
2041
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
47 return DW_EDGE_ENV ? TRUE : FALSE;
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
48 }
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
49
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
50 /******************************* dw_edge_action() **************************
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
51 * Implements the functionality of a "Back". "Forward", "Home", "Search",
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
52 * "Refresh", or "Stop" button.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
53 *
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
54 * hwnd = Handle to the window hosting the browser object.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
55 * action = One of the following:
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
56 * 0 = Move back to the previously viewed web page.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
57 * 1 = Move forward to the previously viewed web page.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
58 * 2 = Move to the home page.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
59 * 3 = Search.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
60 * 4 = Refresh the page.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
61 * 5 = Stop the currently loading page.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
62 */
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
63
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
64 void _dw_edge_action(HWND hwnd, int action)
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
65 {
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
66 IWebView2WebView* webview;
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
67
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
68 // Retrieve the browser object's pointer we stored in our window's GWL_USERDATA when
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
69 // we initially attached the browser object to this window.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
70 webview = (IWebView2WebView*)dw_window_get_data(hwnd, _DW_HTML_DATA_NAME);
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
71
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
72 // We want to get the base address (ie, a pointer) to the IWebView2WebView object embedded within the browser
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
73 // object, so we can call some of the functions in the former's table.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
74 if (webview)
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
75 {
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
76 // Call the desired function
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
77 switch (action)
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
78 {
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
79 case DW_HTML_GOBACK:
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
80 {
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
81 // Call the IWebView2WebView object's GoBack function.
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
82 webview->GoBack();
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
83 break;
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
84 }
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
85
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
86 case DW_HTML_GOFORWARD:
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
87 {
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
88 // Call the IWebView2WebView object's GoForward function.
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
89 webview->GoForward();
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
90 break;
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
91 }
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
92
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
93 case DW_HTML_GOHOME:
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
94 {
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
95 // Call the IWebView2WebView object's GoHome function.
2015
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
96 dw_html_url(hwnd, (char *)DW_HOME_URL);
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
97 break;
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
98 }
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
99
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
100 case DW_HTML_SEARCH:
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
101 {
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
102 // Call the IWebView2WebView object's GoSearch function.
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
103 //webview->GoSearch();
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
104 break;
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
105 }
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
106
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
107 case DW_HTML_RELOAD:
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
108 {
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
109 // Call the IWebView2WebView object's Refresh function.
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
110 webview->Reload();
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
111 }
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
112
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
113 case DW_HTML_STOP:
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
114 {
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
115 // Call the IWebView2WebView object's Stop function.
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
116 //webview->Stop();
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
117 }
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
118 }
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
119 }
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
120 }
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
121
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
122 /******************************* dw_edge_raw() ****************************
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
123 * Takes a string containing some HTML BODY, and displays it in the specified
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
124 * window. For example, perhaps you want to display the HTML text of...
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
125 *
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
126 * <P>This is a picture.<P><IMG src="mypic.jpg">
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
127 *
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
128 * hwnd = Handle to the window hosting the browser object.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
129 * string = Pointer to nul-terminated string containing the HTML BODY.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
130 * (NOTE: No <BODY></BODY> tags are required in the string).
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
131 *
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
132 * RETURNS: 0 if success, or non-zero if an error.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
133 */
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
134
2034
89d62197124b Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2033
diff changeset
135 int _dw_edge_raw(HWND hwnd, const char *string)
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
136 {
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
137 IWebView2WebView* webview;
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
138
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
139 // Retrieve the browser object's pointer we stored in our window's GWL_USERDATA when
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
140 // we initially attached the browser object to this window.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
141 webview = (IWebView2WebView*)dw_window_get_data(hwnd, _DW_HTML_DATA_NAME);
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
142
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
143 if (webview)
2018
663d79f28e46 Win: Fix dw_html_javascript_run() when using embedded IE browser widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2015
diff changeset
144 webview->NavigateToString(UTF8toWide(string));
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
145 else
2018
663d79f28e46 Win: Fix dw_html_javascript_run() when using embedded IE browser widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2015
diff changeset
146 dw_window_set_data(hwnd, _DW_HTML_DATA_RAW, _wcsdup(UTF8toWide(string)));
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
147 return DW_ERROR_NONE;
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
148 }
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
149
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
150 /******************************* dw_edge_url() ****************************
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
151 * Displays a URL, or HTML file on disk.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
152 *
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
153 * hwnd = Handle to the window hosting the browser object.
2015
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
154 * url = Pointer to nul-terminated name of the URL/file.
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
155 *
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
156 * RETURNS: 0 if success, or non-zero if an error.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
157 */
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
158
2034
89d62197124b Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2033
diff changeset
159 int _dw_edge_url(HWND hwnd, const char *url)
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
160 {
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
161 IWebView2WebView* webview;
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
162
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
163 // Retrieve the browser object's pointer we stored in our window's GWL_USERDATA when
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
164 // we initially attached the browser object to this window.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
165 webview = (IWebView2WebView*)dw_window_get_data(hwnd, _DW_HTML_DATA_NAME);
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
166
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
167 if (webview)
2018
663d79f28e46 Win: Fix dw_html_javascript_run() when using embedded IE browser widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2015
diff changeset
168 webview->Navigate(UTF8toWide(url));
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
169 else
2018
663d79f28e46 Win: Fix dw_html_javascript_run() when using embedded IE browser widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2015
diff changeset
170 dw_window_set_data(hwnd, _DW_HTML_DATA_LOCATION, _wcsdup(UTF8toWide(url)));
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
171 return DW_ERROR_NONE;
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
172 }
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
173
2015
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
174 /******************************* dw_edge_javascript_run() ****************************
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
175 * Runs a javascript in the specified browser context.
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
176 *
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
177 * hwnd = Handle to the window hosting the browser object.
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
178 * script = Pointer to nul-terminated javascript string.
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
179 * scriptdata = Pointer to user data to be passed to the callback.
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
180 *
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
181 * RETURNS: 0 if success, or non-zero if an error.
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
182 */
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
183
2034
89d62197124b Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2033
diff changeset
184 int _dw_edge_javascript_run(HWND hwnd, const char *script, void *scriptdata)
2015
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
185 {
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
186 IWebView2WebView* webview;
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
187
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
188 // Retrieve the browser object's pointer we stored in our window's GWL_USERDATA when
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
189 // we initially attached the browser object to this window.
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
190 webview = (IWebView2WebView*)dw_window_get_data(hwnd, _DW_HTML_DATA_NAME);
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
191
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
192 if (webview)
2018
663d79f28e46 Win: Fix dw_html_javascript_run() when using embedded IE browser widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2015
diff changeset
193 webview->ExecuteScript(UTF8toWide(script),
2015
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
194 Callback<IWebView2ExecuteScriptCompletedHandler>(
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
195 [hwnd, scriptdata](HRESULT error, PCWSTR result) -> HRESULT
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
196 {
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
197 _wndproc(hwnd, WM_USER + 100, (error == S_OK ? (WPARAM)WideToUTF8((LPWSTR)result) : NULL), (LPARAM)scriptdata);
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
198 return S_OK;
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
199 }).Get());
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
200 return DW_ERROR_NONE;
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
201 }
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
202
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
203 /************************** edgeWindowProc() *************************
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
204 * Our message handler for our window to host the browser.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
205 */
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
206
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
207 LRESULT CALLBACK _edgeWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
208 {
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
209 switch (uMsg)
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
210 {
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
211 case WM_SIZE:
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
212 {
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
213 // Resize the browser object to fit the window
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
214 IWebView2WebView* webview;
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
215
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
216 // Retrieve the browser object's pointer we stored in our window's GWL_USERDATA when
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
217 // we initially attached the browser object to this window.
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
218 webview = (IWebView2WebView*)dw_window_get_data(hWnd, _DW_HTML_DATA_NAME);
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
219 // Resize WebView to fit the bounds of the parent window
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
220 if (webview)
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
221 {
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
222 RECT bounds;
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
223
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
224 GetClientRect(hWnd, &bounds);
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
225 webview->put_Bounds(bounds);
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
226 }
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
227 return(0);
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
228 }
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
229
2034
89d62197124b Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2033
diff changeset
230 case WM_PAINT:
89d62197124b Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2033
diff changeset
231 {
89d62197124b Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2033
diff changeset
232 PAINTSTRUCT ps;
89d62197124b Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2033
diff changeset
233 HDC hdc = BeginPaint(hWnd, &ps);
89d62197124b Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2033
diff changeset
234 EndPaint(hWnd, &ps);
89d62197124b Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2033
diff changeset
235 return(0);
89d62197124b Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2033
diff changeset
236 }
89d62197124b Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2033
diff changeset
237
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
238 case WM_CREATE:
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
239 {
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
240 // Step 3 - Create a single WebView within the parent window
2041
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
241 // Create a WebView, whose parent is the main window hWnd
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
242 DW_EDGE_ENV->CreateWebView(hWnd, Callback<IWebView2CreateWebViewCompletedHandler>(
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
243 [hWnd](HRESULT result, IWebView2WebView* webview) -> HRESULT {
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
244 if (webview != nullptr) {
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
245 dw_window_set_data(hWnd, _DW_HTML_DATA_NAME, DW_POINTER(webview));
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
246 }
2034
89d62197124b Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2033
diff changeset
247
2041
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
248 // Add a few settings for the webview
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
249 // this is a redundant demo step as they are the default settings values
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
250 IWebView2Settings* Settings;
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
251 webview->get_Settings(&Settings);
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
252 Settings->put_IsScriptEnabled(TRUE);
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
253 Settings->put_AreDefaultScriptDialogsEnabled(TRUE);
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
254 Settings->put_IsWebMessageEnabled(TRUE);
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
255
2041
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
256 // Resize WebView to fit the bounds of the parent window
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
257 RECT bounds;
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
258 GetClientRect(hWnd, &bounds);
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
259 webview->put_Bounds(bounds);
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
260
2041
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
261 // Save the token, we might need to dw_window_set_data() this value
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
262 // for later use to remove the handlers
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
263 EventRegistrationToken token;
2033
d81d2ea806c6 Win: Added callback handlers to generate the HTML_CHANGED signals using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2022
diff changeset
264
2041
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
265 // Register a handler for the NavigationStarting event.
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
266 webview->add_NavigationStarting(
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
267 Callback<IWebView2NavigationStartingEventHandler>(
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
268 [hWnd](IWebView2WebView* sender,
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
269 IWebView2NavigationStartingEventArgs* args) -> HRESULT
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
270 {
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
271 LPWSTR uri;
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
272 sender->get_Source(&uri);
2033
d81d2ea806c6 Win: Added callback handlers to generate the HTML_CHANGED signals using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2022
diff changeset
273
2041
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
274 _wndproc(hWnd, WM_USER + 101, (WPARAM)DW_INT_TO_POINTER(DW_HTML_CHANGE_STARTED),
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
275 !wcscmp(uri, L"about:blank") ? (LPARAM)"" : (LPARAM)WideToUTF8((LPWSTR)uri));
2033
d81d2ea806c6 Win: Added callback handlers to generate the HTML_CHANGED signals using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2022
diff changeset
276
2041
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
277 return S_OK;
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
278 }).Get(), &token);
2033
d81d2ea806c6 Win: Added callback handlers to generate the HTML_CHANGED signals using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2022
diff changeset
279
2041
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
280 // Register a handler for the DocumentStateChanged event.
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
281 webview->add_DocumentStateChanged(
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
282 Callback<IWebView2DocumentStateChangedEventHandler>(
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
283 [hWnd](IWebView2WebView* sender,
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
284 IWebView2DocumentStateChangedEventArgs* args) -> HRESULT
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
285 {
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
286 LPWSTR uri;
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
287 sender->get_Source(&uri);
2033
d81d2ea806c6 Win: Added callback handlers to generate the HTML_CHANGED signals using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2022
diff changeset
288
2041
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
289 _wndproc(hWnd, WM_USER + 101, (WPARAM)DW_INT_TO_POINTER(DW_HTML_CHANGE_LOADING),
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
290 !wcscmp(uri, L"about:blank") ? (LPARAM)"" : (LPARAM)WideToUTF8((LPWSTR)uri));
2033
d81d2ea806c6 Win: Added callback handlers to generate the HTML_CHANGED signals using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2022
diff changeset
291
2041
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
292 return S_OK;
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
293 }).Get(), &token);
2033
d81d2ea806c6 Win: Added callback handlers to generate the HTML_CHANGED signals using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2022
diff changeset
294
2041
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
295 // Register a handler for the NavigationCompleted event.
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
296 webview->add_NavigationCompleted(
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
297 Callback<IWebView2NavigationCompletedEventHandler>(
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
298 [hWnd](IWebView2WebView* sender,
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
299 IWebView2NavigationCompletedEventArgs* args) -> HRESULT
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
300 {
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
301 LPWSTR uri;
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
302 sender->get_Source(&uri);
2033
d81d2ea806c6 Win: Added callback handlers to generate the HTML_CHANGED signals using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2022
diff changeset
303
2041
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
304 _wndproc(hWnd, WM_USER + 101, (WPARAM)DW_INT_TO_POINTER(DW_HTML_CHANGE_COMPLETE),
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
305 !wcscmp(uri, L"about:blank") ? (LPARAM)"" : (LPARAM)WideToUTF8((LPWSTR)uri));
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
306
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
307 return S_OK;
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
308 }).Get(), &token);
2033
d81d2ea806c6 Win: Added callback handlers to generate the HTML_CHANGED signals using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2022
diff changeset
309
2041
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
310 // Handle cached load requests due to delayed
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
311 // loading of the edge webview contexts
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
312 LPCWSTR url = (LPCWSTR)dw_window_get_data(hWnd, _DW_HTML_DATA_LOCATION);
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
313 if(url)
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
314 {
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
315 webview->Navigate(url);
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
316 free((void *)url);
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
317 }
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
318 LPCWSTR raw = (LPCWSTR)dw_window_get_data(hWnd, _DW_HTML_DATA_RAW);
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
319 if (raw)
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
320 {
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
321 webview->NavigateToString(raw);
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
322 free((void *)raw);
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
323 }
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
324 return S_OK;
638be5b17715 Win: Only create one environment during dw_edge_detect() ... if it fails there is no Edge.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2034
diff changeset
325 }).Get());
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
326 // Success
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
327 return(0);
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
328 }
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
329
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
330 case WM_DESTROY:
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
331 {
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
332 // Detach the browser object from this window, and free resources.
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
333 IWebView2WebView* webview;
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
334
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
335 // Retrieve the browser object's pointer we stored in our window's GWL_USERDATA when
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
336 // we initially attached the browser object to this window.
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
337 webview = (IWebView2WebView*)dw_window_get_data(hWnd, _DW_HTML_DATA_NAME);
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
338 if (webview)
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
339 {
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
340 dw_window_set_data(hWnd, _DW_HTML_DATA_NAME, NULL);
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
341 webview->Close();
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
342 }
2033
d81d2ea806c6 Win: Added callback handlers to generate the HTML_CHANGED signals using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2022
diff changeset
343 _free_window_memory(hWnd, 0);
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
344 return(TRUE);
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
345 }
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
346 }
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
347
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
348 return(DefWindowProc(hWnd, uMsg, wParam, lParam));
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
349 }
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
350 }