Mercurial > dwindows
annotate win/edge.cpp @ 2160:07f1366a724c
Rename config.h(.in) to dwconfig.h and install it with dwcompat.
Building modules that use dwcompat requires some of the defines in
dwconfig.h. On some platforms without it the opendir headers are
not included and cause build failures. Unix (Linux, BSD, Solaris
and Mac) are primarily affected.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 29 Sep 2020 22:49:04 +0000 |
parents | a8b55524b1b2 |
children | 05dd5189099f |
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 { |
2127
663467f6eee4
Code cleanup: Add constants to header for dark mode, buffer sizes and Unicode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2124
diff
changeset
|
229 // Combine two buffer lengths, ".WebView2\" (10) and a NULL |
663467f6eee4
Code cleanup: Add constants to header for dark mode, buffer sizes and Unicode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2124
diff
changeset
|
230 WCHAR tempdir[MAX_PATH+_DW_APP_ID_SIZE+11] = {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
|
231 |
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 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
|
233 wcscat(tempdir, AppID); |
2127
663467f6eee4
Code cleanup: Add constants to header for dark mode, buffer sizes and Unicode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2124
diff
changeset
|
234 wcscat(tempdir, L".WebView2\\"); |
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
|
235 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
|
236 |
2154
a8b55524b1b2
Win: Fix CreateCoreWebView2EnvironmentWithOption() failure with no CoInitializeEx().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2127
diff
changeset
|
237 CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); |
a8b55524b1b2
Win: Fix CreateCoreWebView2EnvironmentWithOption() failure with no CoInitializeEx().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2127
diff
changeset
|
238 |
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
|
239 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
|
240 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
|
241 [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
|
242 // 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
|
243 Env = env; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
244 return S_OK; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
245 }).Get()); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
246 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
|
247 } |
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 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
|
250 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
251 // 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
|
252 // 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
|
253 if (WebView) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
254 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
255 // 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
|
256 switch (action) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
257 { |
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
|
258 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
|
259 { |
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 // 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
|
261 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
|
262 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
|
263 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
264 |
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
|
265 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
|
266 { |
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 // 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
|
268 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
|
269 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
|
270 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
271 |
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
|
272 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
|
273 { |
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 // 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
|
275 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
|
276 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
|
277 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
278 |
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
|
279 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
|
280 { |
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 // 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
|
282 //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
|
283 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
|
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_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 { |
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 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
|
289 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
|
290 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
291 |
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
|
292 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
|
293 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
294 // 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
|
295 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
|
296 } |
2042
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 } |
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 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
301 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
|
302 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
303 if (WebView) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
304 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
|
305 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
|
306 } |
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 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
|
309 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
310 if (WebView) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
311 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
|
312 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
|
313 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
314 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
315 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
|
316 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
317 HWND thishwnd = hWnd; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
318 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
319 if (WebView) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
320 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
|
321 Callback<ICoreWebView2ExecuteScriptCompletedHandler>( |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
322 [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
|
323 { |
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
|
324 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
|
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 /* 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
|
327 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
|
328 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
|
329 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
|
330 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
|
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 /* 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
|
333 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
|
334 { |
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 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
|
336 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
|
337 *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
|
338 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
|
339 } |
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
|
340 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
|
341 _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
|
342 return S_OK; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
343 }).Get()); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
344 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
|
345 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
346 |
2065
2dacac5e4023
Win: Updated Edge (Chromium) support for WebView2 SDK 0.9.488.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2060
diff
changeset
|
347 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
|
348 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
349 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
|
350 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
|
351 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
|
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 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
|
355 { |
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
|
356 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
|
357 WebHost->Close(); |
2042
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 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
360 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
|
361 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
362 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
|
363 /******************************* 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
|
364 * 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
|
365 * 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
|
366 * 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
|
367 */ |
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
|
368 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
|
369 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
370 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
|
371 if (DW_EDGE) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
372 { |
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
|
373 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
|
374 if (!result) |
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 delete DW_EDGE; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
377 DW_EDGE = NULL; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
378 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
379 return result; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
380 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
381 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
|
382 } |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
383 |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
384 /******************************* 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
|
385 * 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
|
386 * "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
|
387 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
388 * 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
|
389 * 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
|
390 * 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
|
391 * 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
|
392 * 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
|
393 * 3 = Search. |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
394 * 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
|
395 * 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
|
396 */ |
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 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
|
399 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
400 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
|
401 if (webview) |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
402 webview->Action(action); |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
403 } |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
404 |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
405 /******************************* 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
|
406 * 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
|
407 * 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
|
408 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
409 * <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
|
410 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
411 * 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
|
412 * 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
|
413 * (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
|
414 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
415 * 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
|
416 */ |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
417 |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
418 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
|
419 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
420 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
|
421 if (webview) |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
422 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
|
423 else |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
424 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
|
425 return DW_ERROR_NONE; |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
426 } |
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
427 |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
428 /******************************* 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
|
429 * 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
|
430 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
431 * 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
|
432 * 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
|
433 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
434 * 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
|
435 */ |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
436 |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
437 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
|
438 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
439 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
|
440 if (webview) |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
441 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
|
442 else |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
443 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
|
444 return DW_ERROR_NONE; |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
445 } |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
446 |
2015
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
447 /******************************* 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
|
448 * 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
|
449 * |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
450 * 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
|
451 * 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
|
452 * 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
|
453 * |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
454 * 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
|
455 */ |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
456 |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
457 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
|
458 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
459 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
|
460 if (webview) |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
461 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
|
462 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
|
463 } |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
464 |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
465 /************************** edgeWindowProc() ************************* |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
466 * 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
|
467 */ |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
468 |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
469 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
|
470 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
471 if (DW_EDGE) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
472 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
|
473 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
|
474 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
475 } |