@@ -56,7 +56,7 @@ class CWebWindow
5656 [this , url2, zoom, userAgent, args, deferral, callback2](HRESULT result, ICoreWebView2Controller* controller) -> HRESULT {
5757 if (FAILED (result))
5858 {
59- m_parent->SetToolTipText (L" Failed to create WebView2 controller" );
59+ m_parent->SetErrorToolTipText (L" Failed to create WebView2 controller" );
6060 m_parent->ShowToolTip (true );
6161 }
6262
@@ -267,10 +267,11 @@ class CWebWindow
267267 return m_hWnd;
268268 }
269269
270- HRESULT Create (HINSTANCE hInstance, HWND hWndParent, const wchar_t * url, const wchar_t * userDataFolder,
270+ HRESULT Create (IWebDiffWindow* pDiffWindow, HINSTANCE hInstance, HWND hWndParent, const wchar_t * url, const wchar_t * userDataFolder,
271271 const SIZE& size, bool fitToWindow, double zoom, std::wstring& userAgent,
272272 IWebDiffCallback* callback, std::function<void (WebDiffEvent::EVENT_TYPE, IUnknown*, IUnknown*)> eventHandler)
273273 {
274+ m_pDiffWindow = pDiffWindow;
274275 m_fitToWindow = fitToWindow;
275276 m_size = size;
276277 m_eventHandler = eventHandler;
@@ -1049,7 +1050,7 @@ class CWebWindow
10491050 [this , callback2, msg](HRESULT errorCode, LPCWSTR returnObjectAsJson) -> HRESULT {
10501051 if (FAILED (errorCode))
10511052 {
1052- SetToolTipText (*msg + returnObjectAsJson);
1053+ SetErrorToolTipText (*msg + returnObjectAsJson);
10531054 ShowToolTip (true , TOOLTIP_TIMEOUT);
10541055 }
10551056 if (callback2)
@@ -1069,7 +1070,7 @@ class CWebWindow
10691070 [this , callback2](HRESULT errorCode, LPCWSTR resultObjectAsJson) -> HRESULT {
10701071 if (FAILED (errorCode))
10711072 {
1072- SetToolTipText (resultObjectAsJson);
1073+ SetErrorToolTipText (resultObjectAsJson);
10731074 ShowToolTip (true , TOOLTIP_TIMEOUT);
10741075 }
10751076 if (callback2)
@@ -1092,7 +1093,7 @@ class CWebWindow
10921093 [this , callback2](HRESULT errorCode, LPCWSTR resultObjectAsJson) -> HRESULT {
10931094 if (FAILED (errorCode))
10941095 {
1095- SetToolTipText (resultObjectAsJson);
1096+ SetErrorToolTipText (resultObjectAsJson);
10961097 ShowToolTip (true , TOOLTIP_TIMEOUT);
10971098 }
10981099 if (callback2)
@@ -1107,7 +1108,7 @@ class CWebWindow
11071108 [this , callback2](HRESULT errorCode, LPCWSTR resultObjectAsJson) -> HRESULT {
11081109 if (FAILED (errorCode))
11091110 {
1110- SetToolTipText (resultObjectAsJson);
1111+ SetErrorToolTipText (resultObjectAsJson);
11111112 ShowToolTip (true , TOOLTIP_TIMEOUT);
11121113 }
11131114 if (callback2)
@@ -1309,6 +1310,14 @@ class CWebWindow
13091310 return webView2Profile2->ClearBrowsingData (static_cast <COREWEBVIEW2_BROWSING_DATA_KINDS>(dataKinds), nullptr );
13101311 }
13111312
1313+ HRESULT SetErrorToolTipText (const std::wstring& text)
1314+ {
1315+ IWebDiffWindow::LogCallback logCallback = m_pDiffWindow->GetLogCallback ();
1316+ if (logCallback)
1317+ logCallback (IWebDiffWindow::LogLevel::ERR, text.c_str ());
1318+ return SetToolTipText (text);
1319+ }
1320+
13121321 HRESULT SetToolTipText (const std::wstring& text)
13131322 {
13141323 if (!m_hToolTip)
@@ -2089,5 +2098,6 @@ class CWebWindow
20892098 return reinterpret_cast <decltype (&::GetDpiForWindow)>(
20902099 ::GetProcAddress (hUser32, " GetDpiForWindow" ));
20912100 }();
2101+ IWebDiffWindow* m_pDiffWindow = nullptr ;
20922102};
20932103
0 commit comments