Mercurial > dwindows
annotate win/edge.cpp @ 2123:589896c07c91
Win: Use GetTempPathW() to get a location for the embedded Edge (Chromium) data.
This allows apps to run from \Program Files\ since the apps can't normally write to
this location, prior to this change trying to open a web view would fail after install.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 25 Jun 2020 00:00:48 +0000 |
parents | 9a5dbda8f2ab |
children | f9a2fc59611c |
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); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
33 BOOL Detect(VOID); |
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 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
227 BOOL EdgeBrowser::Detect(VOID) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
228 { |
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
|
229 WCHAR tempdir[MAX_PATH+1]; |
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); |
589896c07c91
Win: Use GetTempPathW() to get a location for the embedded Edge (Chromium) data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2102
diff
changeset
|
232 |
589896c07c91
Win: Use GetTempPathW() to get a location for the embedded Edge (Chromium) data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2102
diff
changeset
|
233 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
|
234 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
|
235 [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
|
236 // 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
|
237 Env = env; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
238 return S_OK; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
239 }).Get()); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
240 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
|
241 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
242 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
243 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
|
244 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
245 // 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
|
246 // 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
|
247 if (WebView) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
248 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
249 // 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
|
250 switch (action) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
251 { |
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
|
252 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
|
253 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
254 // 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
|
255 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
|
256 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
|
257 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
258 |
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
|
259 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
|
260 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
261 // 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
|
262 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
|
263 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
|
264 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
265 |
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
|
266 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
|
267 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
268 // 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
|
269 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
|
270 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
|
271 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
272 |
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
|
273 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
|
274 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
275 // 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
|
276 //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
|
277 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
|
278 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
279 |
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
|
280 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
|
281 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
282 // 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
|
283 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
|
284 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
285 |
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
|
286 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
|
287 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
288 // 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
|
289 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
|
290 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
291 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
292 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
293 } |
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 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
|
296 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
297 if (WebView) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
298 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
|
299 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
|
300 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
301 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
302 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
|
303 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
304 if (WebView) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
305 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
|
306 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
|
307 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
308 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
309 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
|
310 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
311 HWND thishwnd = hWnd; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
312 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
313 if (WebView) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
314 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
|
315 Callback<ICoreWebView2ExecuteScriptCompletedHandler>( |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
316 [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
|
317 { |
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
|
318 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
|
319 |
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
|
320 /* 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
|
321 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
|
322 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
|
323 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
|
324 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
|
325 |
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 /* 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
|
327 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
|
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 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
|
330 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
|
331 *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
|
332 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 } |
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 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
|
335 _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
|
336 return S_OK; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
337 }).Get()); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
338 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
|
339 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
340 |
2065
2dacac5e4023
Win: Updated Edge (Chromium) support for WebView2 SDK 0.9.488.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2060
diff
changeset
|
341 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
|
342 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
343 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
|
344 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
|
345 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
|
346 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
347 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
348 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
|
349 { |
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
|
350 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
|
351 WebHost->Close(); |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
352 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
353 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
354 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
|
355 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
356 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
|
357 /******************************* 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
|
358 * 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
|
359 * 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
|
360 * 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
|
361 */ |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
362 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
|
363 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
364 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
|
365 if (DW_EDGE) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
366 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
367 BOOL result = DW_EDGE->Detect(); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
368 if (!result) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
369 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
370 delete DW_EDGE; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
371 DW_EDGE = NULL; |
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 return result; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
374 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
375 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
|
376 } |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
377 |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
378 /******************************* 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
|
379 * 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
|
380 * "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
|
381 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
382 * 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
|
383 * 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
|
384 * 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
|
385 * 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
|
386 * 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
|
387 * 3 = Search. |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
388 * 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
|
389 * 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
|
390 */ |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
391 |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
392 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
|
393 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
394 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
|
395 if (webview) |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
396 webview->Action(action); |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
397 } |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
398 |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
399 /******************************* 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
|
400 * 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
|
401 * 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
|
402 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
403 * <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
|
404 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
405 * 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
|
406 * 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
|
407 * (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
|
408 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
409 * 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
|
410 */ |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
411 |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
412 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
|
413 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
414 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
|
415 if (webview) |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
416 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
|
417 else |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
418 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
|
419 return DW_ERROR_NONE; |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
420 } |
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
421 |
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 /******************************* 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
|
423 * 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
|
424 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
425 * 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
|
426 * 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
|
427 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
428 * 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
|
429 */ |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
430 |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
431 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
|
432 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
433 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
|
434 if (webview) |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
435 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
|
436 else |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
437 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
|
438 return DW_ERROR_NONE; |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
439 } |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
440 |
2015
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
441 /******************************* 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
|
442 * 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
|
443 * |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
444 * 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
|
445 * 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
|
446 * 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
|
447 * |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
448 * 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
|
449 */ |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
450 |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
451 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
|
452 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
453 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
|
454 if (webview) |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
455 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
|
456 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
|
457 } |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
458 |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
459 /************************** edgeWindowProc() ************************* |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
460 * 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
|
461 */ |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
462 |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
463 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
|
464 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
465 if (DW_EDGE) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
466 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
|
467 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
|
468 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
469 } |