annotate win/edge.cpp @ 2124:f9a2fc59611c

Win: That last fix wasn't tested enough. Create a subfolder with the AppID. The previous fix only allowed one dwindows application instance access to Edge. Create a subdirectory under TEMP with the specified or auto-detected ID. This change made me pull the application ID code out of #ifdef BUILD_TOAST.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 25 Jun 2020 00:38:37 +0000
parents 589896c07c91
children 663467f6eee4
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 #include "dw.h"
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10 #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
11 #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
12
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
13 using namespace Microsoft::WRL;
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
14
2034
89d62197124b Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2033
diff changeset
15 #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
16 #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
17 #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
18
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
19 extern "C" {
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
20
2018
663d79f28e46 Win: Fix dw_html_javascript_run() when using embedded IE browser widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2015
diff changeset
21 /* Import the character conversion functions from dw.c */
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
22 LPWSTR _myUTF8toWide(const char* utf8string, void* outbuf);
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
23 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
24 #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
25 #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
26 LRESULT CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2);
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
27 }
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
28
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
29 class EdgeBrowser
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
30 {
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
31 public:
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
32 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
2124
f9a2fc59611c Win: That last fix wasn't tested enough. Create a subfolder with the AppID.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2123
diff changeset
33 BOOL Detect(LPWSTR AppID);
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
34 protected:
2060
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
35 Microsoft::WRL::ComPtr<ICoreWebView2Environment> Env;
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
36 };
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
37
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
38 class EdgeWebView
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
39 {
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
40 public:
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
41 VOID Action(int action);
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
42 int Raw(const char* string);
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
43 int URL(const char* url);
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
44 int JavascriptRun(const char* script, void* scriptdata);
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
45 VOID DoSize(VOID);
2065
2dacac5e4023 Win: Updated Edge (Chromium) support for WebView2 SDK 0.9.488.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2060
diff changeset
46 VOID Setup(HWND hwnd, ICoreWebView2Controller* webview);
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
47 VOID Close(VOID);
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
48 protected:
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
49 HWND hWnd = nullptr;
2060
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
50 Microsoft::WRL::ComPtr<ICoreWebView2> WebView;
2065
2dacac5e4023 Win: Updated Edge (Chromium) support for WebView2 SDK 0.9.488.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2060
diff changeset
51 Microsoft::WRL::ComPtr<ICoreWebView2Controller> WebHost;
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
52 };
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
53
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
54 LRESULT CALLBACK EdgeBrowser::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
55 {
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
56 switch (uMsg)
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
57 {
2043
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
58 case WM_SIZE:
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
59 {
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
60 // Resize the browser object to fit the window
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
61 EdgeWebView *webview;
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
62
2043
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
63 // Retrieve the browser object's pointer we stored in our window's GWL_USERDATA when
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
64 // we initially attached the browser object to this window.
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
65 webview = (EdgeWebView*)dw_window_get_data(hWnd, _DW_HTML_DATA_NAME);
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
66 // Resize WebView to fit the bounds of the parent window
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
67 if (webview)
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
68 webview->DoSize();
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
69 return(0);
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
70 }
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
71
2043
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
72 case WM_PAINT:
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
73 {
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
74 PAINTSTRUCT ps;
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
75 HDC hdc = BeginPaint(hWnd, &ps);
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
76 EndPaint(hWnd, &ps);
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
77 return(0);
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
78 }
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
79
2043
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
80 case WM_CREATE:
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
81 {
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
82 // Step 3 - Create a single WebView within the parent window
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
83 // Create a WebView, whose parent is the main window hWnd
2065
2dacac5e4023 Win: Updated Edge (Chromium) support for WebView2 SDK 0.9.488.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2060
diff changeset
84 Env->CreateCoreWebView2Controller(hWnd, Callback<ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>(
2dacac5e4023 Win: Updated Edge (Chromium) support for WebView2 SDK 0.9.488.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2060
diff changeset
85 [hWnd](HRESULT result, ICoreWebView2Controller* webhost) -> HRESULT {
2043
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
86 EdgeWebView* WebView = new EdgeWebView;
2060
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
87 ICoreWebView2* webview;
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
88
2060
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
89 WebView->Setup(hWnd, webhost);
2043
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
90 dw_window_set_data(hWnd, _DW_HTML_DATA_NAME, DW_POINTER(WebView));
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
91
2060
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
92 if (SUCCEEDED(webhost->get_CoreWebView2(&webview))) {
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
93 // Add a few settings for the webview
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
94 // this is a redundant demo step as they are the default settings values
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
95 ICoreWebView2Settings* Settings;
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
96 webview->get_Settings(&Settings);
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
97 Settings->put_IsScriptEnabled(TRUE);
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
98 Settings->put_AreDefaultScriptDialogsEnabled(TRUE);
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
99 Settings->put_IsWebMessageEnabled(TRUE);
2045
cb195d76de8e Win: Make HTML_RESULT event match other platforms and disable dev tools when not DEBUG.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2044
diff changeset
100 #ifndef DEBUG
2060
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
101 Settings->put_AreDevToolsEnabled(FALSE);
2045
cb195d76de8e Win: Make HTML_RESULT event match other platforms and disable dev tools when not DEBUG.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2044
diff changeset
102 #endif
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
103
2060
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
104 // Save the token, we might need to dw_window_set_data() this value
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
105 // for later use to remove the handlers
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
106 EventRegistrationToken token;
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
107
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
108 // Register a handler for the NavigationStarting event.
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
109 webview->add_NavigationStarting(
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
110 Callback<ICoreWebView2NavigationStartingEventHandler>(
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
111 [hWnd](ICoreWebView2* sender,
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
112 ICoreWebView2NavigationStartingEventArgs* args) -> HRESULT
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
113 {
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
114 LPWSTR uri;
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
115 sender->get_Source(&uri);
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
116
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
117 _wndproc(hWnd, WM_USER + 101, (WPARAM)DW_INT_TO_POINTER(DW_HTML_CHANGE_STARTED),
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
118 !wcscmp(uri, L"about:blank") ? (LPARAM)"" : (LPARAM)WideToUTF8((LPWSTR)uri));
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
119
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
120 return S_OK;
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
121 }).Get(), &token);
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
122
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
123 // Register a handler for the SourceChanged event.
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
124 webview->add_SourceChanged(
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
125 Callback<ICoreWebView2SourceChangedEventHandler >(
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
126 [hWnd](ICoreWebView2* sender,
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
127 ICoreWebView2SourceChangedEventArgs* args) -> HRESULT
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
128 {
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
129 LPWSTR uri;
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
130 sender->get_Source(&uri);
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
131
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
132 _wndproc(hWnd, WM_USER + 101, (WPARAM)DW_INT_TO_POINTER(DW_HTML_CHANGE_REDIRECT),
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
133 !wcscmp(uri, L"about:blank") ? (LPARAM)"" : (LPARAM)WideToUTF8((LPWSTR)uri));
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
134
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
135 return S_OK;
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
136 }).Get(), &token);
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
137
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
138 // Register a handler for the ContentLoading event.
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
139 webview->add_ContentLoading(
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
140 Callback<ICoreWebView2ContentLoadingEventHandler >(
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
141 [hWnd](ICoreWebView2* sender,
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
142 ICoreWebView2ContentLoadingEventArgs* args) -> HRESULT
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
143 {
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
144 LPWSTR uri;
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
145 sender->get_Source(&uri);
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
146
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
147 _wndproc(hWnd, WM_USER + 101, (WPARAM)DW_INT_TO_POINTER(DW_HTML_CHANGE_LOADING),
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
148 !wcscmp(uri, L"about:blank") ? (LPARAM)"" : (LPARAM)WideToUTF8((LPWSTR)uri));
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
149
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
150 return S_OK;
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
151 }).Get(), &token);
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
152
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
153 // Register a handler for the NavigationCompleted event.
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
154 webview->add_NavigationCompleted(
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
155 Callback<ICoreWebView2NavigationCompletedEventHandler>(
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
156 [hWnd](ICoreWebView2* sender,
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
157 ICoreWebView2NavigationCompletedEventArgs* args) -> HRESULT
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
158 {
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
159 LPWSTR uri;
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
160 sender->get_Source(&uri);
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
161
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
162 _wndproc(hWnd, WM_USER + 101, (WPARAM)DW_INT_TO_POINTER(DW_HTML_CHANGE_COMPLETE),
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
163 !wcscmp(uri, L"about:blank") ? (LPARAM)"" : (LPARAM)WideToUTF8((LPWSTR)uri));
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
164
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
165 return S_OK;
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
166 }).Get(), &token);
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
167 }
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
168
2043
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
169 // Resize WebView to fit the bounds of the parent window
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
170 WebView->DoSize();
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
171
2043
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
172 // Handle cached load requests due to delayed
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
173 // loading of the edge webview contexts
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
174 char *url = (char *)dw_window_get_data(hWnd, _DW_HTML_DATA_LOCATION);
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
175 if (url)
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
176 {
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
177 WebView->URL(url);
2085
43453c9a404c Win: Implement DW_HTML_STOP for Edge (Chromium) now that it is suppported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2065
diff changeset
178 dw_window_set_data(hWnd, _DW_HTML_DATA_LOCATION, NULL);
2043
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
179 free((void*)url);
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
180 }
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
181 char *raw = (char *)dw_window_get_data(hWnd, _DW_HTML_DATA_RAW);
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
182 if (raw)
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
183 {
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
184 WebView->Raw(raw);
2085
43453c9a404c Win: Implement DW_HTML_STOP for Edge (Chromium) now that it is suppported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2065
diff changeset
185 dw_window_set_data(hWnd, _DW_HTML_DATA_RAW, NULL);
2043
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
186 free((void*)raw);
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
187 }
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
188 return S_OK;
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
189 }).Get());
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
190 // Success
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
191 return(0);
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
192 }
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
193
2043
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
194 case WM_DESTROY:
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
195 {
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
196 // Detach the browser object from this window, and free resources.
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
197 EdgeWebView *webview;
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
198
2043
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
199 // Retrieve the browser object's pointer we stored in our window's GWL_USERDATA when
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
200 // we initially attached the browser object to this window.
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
201 webview = (EdgeWebView*)dw_window_get_data(hWnd, _DW_HTML_DATA_NAME);
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
202 if (webview)
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
203 {
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
204 dw_window_set_data(hWnd, _DW_HTML_DATA_NAME, NULL);
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
205 webview->Close();
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
206 delete webview;
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
207 }
82e5c998df2e Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2042
diff changeset
208 return(TRUE);
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
209 }
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
210 }
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
211
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
212 return(DefWindowProc(hWnd, uMsg, wParam, lParam));
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
213 }
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
214
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
215 VOID EdgeWebView::DoSize(VOID)
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
216 {
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
217 RECT bounds;
2044
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
218 BOOL isVisible;
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
219
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
220 GetClientRect(hWnd, &bounds);
2060
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
221 WebHost->put_Bounds(bounds);
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
222 WebHost->get_IsVisible(&isVisible);
2044
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
223 if(!isVisible)
2060
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
224 WebHost->put_IsVisible(TRUE);
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
225 }
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
226
2124
f9a2fc59611c Win: That last fix wasn't tested enough. Create a subfolder with the AppID.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2123
diff changeset
227 BOOL EdgeBrowser::Detect(LPWSTR AppID)
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
228 {
2124
f9a2fc59611c Win: That last fix wasn't tested enough. Create a subfolder with the AppID.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2123
diff changeset
229 WCHAR tempdir[MAX_PATH+1] = {0};
2123
589896c07c91 Win: Use GetTempPathW() to get a location for the embedded Edge (Chromium) data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2102
diff changeset
230
589896c07c91 Win: Use GetTempPathW() to get a location for the embedded Edge (Chromium) data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2102
diff changeset
231 GetTempPathW(MAX_PATH, tempdir);
2124
f9a2fc59611c Win: That last fix wasn't tested enough. Create a subfolder with the AppID.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2123
diff changeset
232 wcscat(tempdir, AppID);
f9a2fc59611c Win: That last fix wasn't tested enough. Create a subfolder with the AppID.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2123
diff changeset
233 wcscat(tempdir, L"\\");
f9a2fc59611c Win: That last fix wasn't tested enough. Create a subfolder with the AppID.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2123
diff changeset
234 CreateDirectoryW(tempdir, NULL);
2123
589896c07c91 Win: Use GetTempPathW() to get a location for the embedded Edge (Chromium) data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2102
diff changeset
235
589896c07c91 Win: Use GetTempPathW() to get a location for the embedded Edge (Chromium) data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2102
diff changeset
236 CreateCoreWebView2EnvironmentWithOptions(nullptr, tempdir, nullptr,
2060
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
237 Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>(
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
238 [this](HRESULT result, ICoreWebView2Environment* env) -> HRESULT {
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
239 // Successfully created Edge environment, return TRUE
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
240 Env = env;
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
241 return S_OK;
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
242 }).Get());
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
243 return Env ? TRUE : FALSE;
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
244 }
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
245
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
246 void EdgeWebView::Action(int action)
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
247 {
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
248 // We want to get the base address (ie, a pointer) to the IWebView2WebView object embedded within the browser
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
249 // object, so we can call some of the functions in the former's table.
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
250 if (WebView)
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
251 {
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
252 // Call the desired function
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
253 switch (action)
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
254 {
2044
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
255 case DW_HTML_GOBACK:
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
256 {
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
257 // Call the IWebView2WebView object's GoBack function.
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
258 WebView->GoBack();
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
259 break;
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
260 }
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
261
2044
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
262 case DW_HTML_GOFORWARD:
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
263 {
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
264 // Call the IWebView2WebView object's GoForward function.
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
265 WebView->GoForward();
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
266 break;
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
267 }
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
268
2044
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
269 case DW_HTML_GOHOME:
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
270 {
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
271 // Call the IWebView2WebView object's GoHome function.
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
272 dw_html_url(hWnd, (char*)DW_HOME_URL);
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
273 break;
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
274 }
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
275
2044
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
276 case DW_HTML_SEARCH:
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
277 {
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
278 // Call the IWebView2WebView object's GoSearch function.
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
279 //WebView->GoSearch();
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
280 break;
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
281 }
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
282
2044
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
283 case DW_HTML_RELOAD:
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
284 {
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
285 // Call the IWebView2WebView object's Refresh function.
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
286 WebView->Reload();
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
287 }
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
288
2044
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
289 case DW_HTML_STOP:
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
290 {
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
291 // Call the IWebView2WebView object's Stop function.
2085
43453c9a404c Win: Implement DW_HTML_STOP for Edge (Chromium) now that it is suppported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2065
diff changeset
292 WebView->Stop();
2044
b74b9afa31aa Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2043
diff changeset
293 }
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
294 }
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
295 }
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
296 }
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
297
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
298 int EdgeWebView::Raw(const char* string)
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
299 {
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
300 if (WebView)
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
301 WebView->NavigateToString(UTF8toWide(string));
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
302 return DW_ERROR_NONE;
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
303 }
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
304
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
305 int EdgeWebView::URL(const char* url)
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
306 {
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
307 if (WebView)
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
308 WebView->Navigate(UTF8toWide(url));
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
309 return DW_ERROR_NONE;
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
310 }
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
311
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
312 int EdgeWebView::JavascriptRun(const char* script, void* scriptdata)
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
313 {
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
314 HWND thishwnd = hWnd;
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
315
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
316 if (WebView)
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
317 WebView->ExecuteScript(UTF8toWide(script),
2060
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
318 Callback<ICoreWebView2ExecuteScriptCompletedHandler>(
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
319 [thishwnd, scriptdata](HRESULT error, PCWSTR result) -> HRESULT
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
320 {
2052
cfa0a9554118 Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2045
diff changeset
321 char *scriptresult;
cfa0a9554118 Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2045
diff changeset
322
cfa0a9554118 Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2045
diff changeset
323 /* Result is unquoted "null" when we should return NULL */
2045
cb195d76de8e Win: Make HTML_RESULT event match other platforms and disable dev tools when not DEBUG.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2044
diff changeset
324 if (result && _wcsicmp(result, L"null") == 0)
2052
cfa0a9554118 Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2045
diff changeset
325 scriptresult = NULL;
cfa0a9554118 Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2045
diff changeset
326 else
cfa0a9554118 Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2045
diff changeset
327 scriptresult = result ? WideToUTF8((LPWSTR)result) : NULL;
cfa0a9554118 Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2045
diff changeset
328
cfa0a9554118 Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2045
diff changeset
329 /* String results are enclosed in quotations, remove the quotes */
cfa0a9554118 Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2045
diff changeset
330 if(scriptresult && *scriptresult == '\"')
cfa0a9554118 Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2045
diff changeset
331 {
cfa0a9554118 Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2045
diff changeset
332 char *end = strrchr(scriptresult, '\"');
cfa0a9554118 Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2045
diff changeset
333 if(end)
cfa0a9554118 Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2045
diff changeset
334 *end = '\0';
cfa0a9554118 Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2045
diff changeset
335 scriptresult++;
cfa0a9554118 Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2045
diff changeset
336 }
cfa0a9554118 Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2045
diff changeset
337 void *params[2] = { (void *)scriptresult, DW_INT_TO_POINTER((error == S_OK ? DW_ERROR_NONE : DW_ERROR_UNKNOWN)) };
2045
cb195d76de8e Win: Make HTML_RESULT event match other platforms and disable dev tools when not DEBUG.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2044
diff changeset
338 _wndproc(thishwnd, WM_USER + 100, (WPARAM)params, (LPARAM)scriptdata);
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
339 return S_OK;
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
340 }).Get());
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
341 return DW_ERROR_NONE;
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
342 }
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
343
2065
2dacac5e4023 Win: Updated Edge (Chromium) support for WebView2 SDK 0.9.488.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2060
diff changeset
344 VOID EdgeWebView::Setup(HWND hwnd, ICoreWebView2Controller* host)
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
345 {
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
346 hWnd = hwnd;
2060
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
347 WebHost = host;
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
348 host->get_CoreWebView2(&WebView);
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
349 }
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
350
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
351 VOID EdgeWebView::Close(VOID)
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
352 {
2060
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
353 if (WebHost)
21bc72ff40cb Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2052
diff changeset
354 WebHost->Close();
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
355 }
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
356
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
357 EdgeBrowser *DW_EDGE = NULL;
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
358
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
359 extern "C" {
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
360 /******************************* 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
361 * 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
362 * 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
363 * 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
364 */
2124
f9a2fc59611c Win: That last fix wasn't tested enough. Create a subfolder with the AppID.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2123
diff changeset
365 BOOL _dw_edge_detect(LPWSTR AppID)
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
366 {
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
367 DW_EDGE = new EdgeBrowser;
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
368 if (DW_EDGE)
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
369 {
2124
f9a2fc59611c Win: That last fix wasn't tested enough. Create a subfolder with the AppID.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2123
diff changeset
370 BOOL result = DW_EDGE->Detect(AppID);
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
371 if (!result)
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
372 {
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
373 delete DW_EDGE;
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
374 DW_EDGE = NULL;
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
375 }
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
376 return result;
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
377 }
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
378 return FALSE;
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
379 }
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
380
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
381 /******************************* 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
382 * 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
383 * "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
384 *
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
385 * 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
386 * 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
387 * 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
388 * 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
389 * 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
390 * 3 = Search.
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
391 * 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
392 * 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
393 */
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
394
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
395 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
396 {
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
397 EdgeWebView* webview = (EdgeWebView *)dw_window_get_data(hwnd, _DW_HTML_DATA_NAME);
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
398 if (webview)
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
399 webview->Action(action);
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
400 }
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
401
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
402 /******************************* 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
403 * 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
404 * 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
405 *
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
406 * <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
407 *
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
408 * 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
409 * 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
410 * (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
411 *
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
412 * 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
413 */
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
414
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
415 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
416 {
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
417 EdgeWebView* webview = (EdgeWebView*)dw_window_get_data(hwnd, _DW_HTML_DATA_NAME);
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
418 if (webview)
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
419 return webview->Raw(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
420 else
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
421 dw_window_set_data(hwnd, _DW_HTML_DATA_RAW, strdup(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
422 return DW_ERROR_NONE;
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
423 }
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
424
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
425 /******************************* 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
426 * 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
427 *
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
428 * 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
429 * 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
430 *
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
431 * 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
432 */
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
433
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
434 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
435 {
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
436 EdgeWebView* webview = (EdgeWebView*)dw_window_get_data(hwnd, _DW_HTML_DATA_NAME);
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
437 if (webview)
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
438 return webview->URL(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
439 else
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
440 dw_window_set_data(hwnd, _DW_HTML_DATA_LOCATION, strdup(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
441 return DW_ERROR_NONE;
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
442 }
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
443
2015
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
444 /******************************* 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
445 * 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
446 *
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
447 * 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
448 * 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
449 * 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
450 *
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
451 * 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
452 */
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
453
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
454 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
455 {
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
456 EdgeWebView* webview = (EdgeWebView*)dw_window_get_data(hwnd, _DW_HTML_DATA_NAME);
2015
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
457 if (webview)
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
458 return webview->JavascriptRun(script, scriptdata);
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
459 return DW_ERROR_UNKNOWN;
2015
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
460 }
c30f4354966e Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2001
diff changeset
461
2001
f7acca46f795 Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2000
diff changeset
462 /************************** edgeWindowProc() *************************
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
463 * 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
464 */
1999
4e808c4cadfb Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
465
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
466 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
467 {
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
468 if (DW_EDGE)
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
469 return DW_EDGE->WndProc(hWnd, uMsg, wParam, lParam);
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
470 return DefWindowProc(hWnd, uMsg, wParam, lParam);
2000
77e43d71eaa7 Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1999
diff changeset
471 }
2042
0d8b898b03e2 Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2041
diff changeset
472 }